Skip to content

feat: add premium tiers table#1684

Merged
manuelsc merged 4 commits intostagingfrom
nobeds/add_premium_tiers
Aug 25, 2025
Merged

feat: add premium tiers table#1684
manuelsc merged 4 commits intostagingfrom
nobeds/add_premium_tiers

Conversation

@manuelsc
Copy link
Contributor

No description provided.

-- +goose StatementBegin

CREATE TABLE IF NOT EXISTS premium_tiers (
purchase_id VARCHAR(255) NOT NULL,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subscription_id


CREATE TABLE IF NOT EXISTS premium_tiers (
purchase_id VARCHAR(255) NOT NULL,
tier_id VARCHAR(255) NOT NULL,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tier_name

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add constraints enforcing the tier names which match the code types

END$$;

CREATE TABLE IF NOT EXISTS subscription_tiers (
price_id VARCHAR(255) NOT NULL,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call this explicitly stripe_*, because then whoever sees this variable is going to know exactly where it comes from. Otherwise, they have to guess.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I thought we were going to rename this to stripe_subscription_id. Are we sure price is right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it was my bad, I confused subscription id and price id in the call but checked after to make sure I get this right. Price ID is the correct one (identifying what the user purchased, subscription is is just the id of that specific user subscription).

As for the stripe prefix. In theory we could use this table for a generic implementation. It's just a mapping between any third party identifier of a thing a user can by to our local reference for it. That's why I'd argue against tying it to strongly to stripe

CREATE TABLE IF NOT EXISTS subscription_tiers (
price_id VARCHAR(255) NOT NULL,
tier_name tier_enum NOT NULL,
PRIMARY KEY (price_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The primary key should be tier_name, not price_id, right? Otherwise it could be possible to accidentally add in multiple tiers with the same name but different price_ids, and the code will break.

@manuelsc manuelsc merged commit b43de40 into staging Aug 25, 2025
2 checks passed
@manuelsc manuelsc deleted the nobeds/add_premium_tiers branch August 25, 2025 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants