Skip to content

Commit b43de40

Browse files
committed
misc: add version
1 parent 29f7d06 commit b43de40

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

backend/pkg/commons/db/migrations/postgres/20250819120437_premium_tiers.sql

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,45 @@ BEGIN
99
END IF;
1010
END$$;
1111

12+
-- create enum type for version
13+
DO $$
14+
BEGIN
15+
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'subscription_version_enum') THEN
16+
CREATE TYPE subscription_version_enum AS ENUM ('stripe_v3', 'stripe_legacy');
17+
END IF;
18+
END$$;
19+
1220
CREATE TABLE IF NOT EXISTS subscription_tiers (
1321
price_id VARCHAR(255) NOT NULL,
1422
tier_name tier_enum NOT NULL,
23+
version subscription_version_enum NOT NULL,
1524
PRIMARY KEY (price_id)
1625
);
1726

27+
COMMENT ON COLUMN subscription_tiers.price_id IS 'Unique subscription price identifier (e.g. Stripe price ID)';
28+
COMMENT ON COLUMN subscription_tiers.tier_name IS 'Our subscription tier this price belongs to. Valid values: FREE, HOBBYIST, BUSINESS, SCALE';
29+
COMMENT ON COLUMN subscription_tiers.version IS 'Integration version. Valid values: stripe_v3 (current) or stripe_legacy (v1).';
30+
1831
-- +goose StatementEnd
1932

2033
-- +goose Down
2134
-- +goose StatementBegin
2235

2336
DROP TABLE IF EXISTS subscription_tiers;
2437

25-
-- drop enum type only if it exists (and table no longer depends on it)
38+
-- drop enums if no longer used
2639
DO $$
2740
BEGIN
2841
IF EXISTS (SELECT 1 FROM pg_type WHERE typname = 'tier_enum') THEN
2942
DROP TYPE tier_enum;
3043
END IF;
3144
END$$;
3245

46+
DO $$
47+
BEGIN
48+
IF EXISTS (SELECT 1 FROM pg_type WHERE typname = 'subscription_version_enum') THEN
49+
DROP TYPE subscription_version_enum;
50+
END IF;
51+
END$$;
52+
3353
-- +goose StatementEnd

0 commit comments

Comments
 (0)