tenseleyflow/shithub / 75b7d7c

Browse files

migrations: user_plan enum + users.plan column

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
75b7d7c0a9a69acd47d2faf8fa6151c55276cd1f
Parents
f6b0603
Tree
b379d94

1 changed file

StatusFile+-
A internal/migrationsfs/migrations/0071_user_plan_enum.sql 27 0
internal/migrationsfs/migrations/0071_user_plan_enum.sqladded
@@ -0,0 +1,27 @@
1
+-- SPDX-License-Identifier: AGPL-3.0-or-later
2
+--
3
+-- PAYMENTS PRO03 — user-tier plan enum.
4
+--
5
+-- Personal accounts get a `user_plan` enum mirroring `org_plan`'s
6
+-- role, but with values disjoint from the org tier. PRO02 Q2 ratified
7
+-- separate enums: Free orgs and Free personal accounts share a label
8
+-- but have different semantics (orgs carry seat counts; users don't),
9
+-- and future SKUs on one side shouldn't pollute the other's namespace.
10
+--
11
+-- `users.plan` defaults to 'free'. Existing rows pick up the default
12
+-- automatically; no explicit backfill needed.
13
+
14
+-- +goose Up
15
+
16
+CREATE TYPE user_plan AS ENUM ('free', 'pro');
17
+
18
+ALTER TABLE users
19
+    ADD COLUMN plan user_plan NOT NULL DEFAULT 'free';
20
+
21
+CREATE INDEX users_plan_idx ON users (plan) WHERE plan <> 'free';
22
+
23
+-- +goose Down
24
+
25
+DROP INDEX IF EXISTS users_plan_idx;
26
+ALTER TABLE users DROP COLUMN IF EXISTS plan;
27
+DROP TYPE IF EXISTS user_plan;