MySQL · 900 bytes Raw Blame History
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;
28