fix: isolate AANTS subscriptions by environment#1536
Merged
IsaacNguyen merged 4 commits intoicssc:mainfrom Apr 15, 2026
Merged
Conversation
Backfill NULL/empty environment values to 'production', set NOT NULL with default, and include environment in the composite primary key so subscriptions from different deployment stages don't collide.
Add environment parameter to all RDS notification methods and filter queries by it. Resolve STAGE env var in every tRPC handler (defaulting to 'production') so each deployment only sees its own subscriptions.
IsaacNguyen
previously approved these changes
Mar 31, 2026
Contributor
IsaacNguyen
left a comment
There was a problem hiding this comment.
So sorry for taking so long to get around to this, but great job on the PR! Everything looks good to me!
I'm not sure I'm the biggest fan of defaulting the stage to "production", but we kind of have to in this situation (I would've done the same).
I think we should hold off from merging this one until after Spring enrollment is completely done (maybe after Week 2).
Contributor
|
Hello! Sorry for the delay in getting this merged (there are some merge conflicts now). But once you squash these conflicts, we'll get this merged in! |
6dd719c to
765d249
Compare
Contributor
Author
|
migration looks clean |
dsnsgithub
pushed a commit
that referenced
this pull request
Apr 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses #1530
Staging and prod AANTS instances share the same DB. Previously, subs created on staging would be visible in prod (and vice versa) and the tRPC backend would return/modify subs across environments.
This PR makes
environmenta required part of each subscription so each env is isolated.Changes
migration (
0009_handy_prima.sql)environmentto'production'where it wasNULLor''environmentNOT NULLwith a default of'production'(userId, sectionCode, year, quarter)→(userId, sectionCode, year, quarter, environment)schema (
subscription.ts)environmentcolumn: nullable →notNull().default('production')environmentbackend (
rds.ts+notifications.ts)retrieve,upsert,updateAll,delete,deleteAll) now filter byenvironmentgetStage()helper readsprocess.env.STAGE, defaulting to'production'(the oldsethandler was the only one that readSTAGE, and it fell back to'')upsertconflict target updated to includeenvironment, andenvironmentremoved from theonConflictDoUpdateset (since it's now part of the PK)Test plan
NULL/empty environments backfill to'production'environment = 'production'