Skip to content

feat(subscriptions): add postgres connection and alembic migrations - #8563

Open
ldelvoye wants to merge 1 commit into
masterfrom
ldelvoye/feat/subscriptions-postgres-tooling
Open

ldelvoye wants to merge 1 commit into
masterfrom
ldelvoye/feat/subscriptions-postgres-tooling

Conversation

@ldelvoye

Copy link
Copy Markdown
Member

resolves INFRENG-678

Adds a Postgres connection and alembic migrations for the subscription store, with a first migration creating the subscriptions table and a snuba subscriptions-postgres migrate command to run it. Nothing reads or writes the table yet; that comes with the store itself in INFRENG-679.

I put the migrations in snuba/subscriptions/postgres/migrations/, next to the code that'll use them, and they run on plain alembic. They have nothing to do with snuba's ClickHouse migration system: there's no group to register, and snuba migrations never sees them. I did consider putting them under snuba/snuba_migrations/ so all of snuba's migrations live in one place, but the tooling there assumes ClickHouse (check-migrations.py would fail this PR for mixing migrations with other code, and ddl-changes.py would parse them as ClickHouse DDL). Keeping them with the feature is also how sentry does it with Django, where each app has its own migrations/ folder. If you'd rather have everything in one place, I'm happy to move them.

Sets up the Postgres side of the subscription store: settings for the
app and migrations URLs, a pgbouncer-safe engine, the subscriptions
table, and a migrate command. The devserver and CI get a local Postgres.
@ldelvoye
ldelvoye requested a review from a team as a code owner October 19, 2026 16:52
@linear-code

linear-code Bot commented Oct 19, 2026

Copy link
Copy Markdown

INFRENG-678

@pbhandari pbhandari left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have some pretty strong objections to us introducing a completely separate method of doing these migrations. This is a pretty big footgun we'd always have to remember whenever we're working with subscriptions. I'd very much prefer if this was done using the existing migraition system.

If the addition of postgres, and it's migrations, make our tooling assumptions invalid, then the tooling assumptions to be updated.

At the very least I'd like to make sure that snuba migrate continues to behave as expected. Happy to get on a call to discuss options to get us to that state.

Comment on lines +185 to +186
SUBSCRIPTIONS_POSTGRES_URL = os.environ.get("SUBSCRIPTIONS_POSTGRES_URL")
SUBSCRIPTIONS_POSTGRES_MIGRATIONS_URL = os.environ.get("SUBSCRIPTIONS_POSTGRES_MIGRATIONS_URL")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

While we are currently using postgres for subscriptions; we shouldn't bake that into the name. I'd much prefer if we dropped teh subscriptions prefix.

This branch has not been deployed

No deployments
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