fix: re-apply the two migrations that share a version - #66
Merged
Conversation
20260815140000_assignment_parent_session.sql (#52) and 20260815140000_roster_revoke_anon_read.sql (#48) landed with the same version prefix. Supabase records an applied migration by timestamp as its unique id and compares only timestamps, so the second is treated as already applied and skipped, silently. One of them has never run, and which one depends on when a given database last migrated. If it is the revoke, anon and authenticated still hold select on roster_students -- the table carrying the free-text adaptations column. That is inert only while RLS has no policies, which is a fail-closed accident rather than a design. Forward-only rather than renaming the originals, which would rewrite deployed history: every statement here is idempotent, so it is a no-op where both applied and a repair where either was skipped.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
20260815140000_assignment_parent_session.sql(#52) and20260815140000_roster_revoke_anon_read.sql(#48) were written on parallel branches and landed with the same version prefix.Supabase records an applied migration by that timestamp as its unique id, and
migration listcompares only timestamps. So once20260815140000is recorded, the other file carrying it is treated as already applied and skipped — with no error and no output.One of these two has therefore never run on any database built from this repo, and which one depends on when that database last migrated:
assignments.parent_session_idis missing and the dashboard's parent/child session grouping breaks. Loud, easy to spot.anon/authenticatedstill holdselectonroster_students, which carriesadaptations— the free-text column the UI solicits IEP and accommodation notes into.The second is the one that matters, and it fails silently. That grant is inert today only because RLS is enabled with no policies, which denies everything — a fail-closed accident, as the original migration's own comment says. It stops being inert the first time anyone adds a permissive policy, which is the natural next step when teacher auth arrives. At that point it becomes a public read of the whole roster through the client-visible anon key.
Why forward-only rather than renaming
#62 renamed both files to fresh versions. That works, but rewrites migration history that is already deployed. This adds one new migration instead and touches nothing existing.
Every statement is idempotent —
add column if not exists,create index if not exists, andrevoke(revoking a privilege that was never granted is a no-op in Postgres). So it is a no-op on a database where both already applied, and a repair on one where either was skipped.Checking which state you are actually in
Not required before merging — the migration is safe either way — but if you want to know:
Not verified locally
There is no Docker on this machine, so I could not stand up a local Supabase and reproduce the skip. The mechanism is from the Supabase documentation, not from observation;
supabase db reseton a machine with Docker would confirm both the problem and this fix.