-
Notifications
You must be signed in to change notification settings - Fork 0
docs: add migration history notes and pre-launch squash plan #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # Migration History Notes | ||
|
|
||
| ## Date: 2026-06-03 | ||
|
|
||
| ### Context | ||
| During the review and integration of PR #19 and PR #20, the local workspace tracking for migrations diverged from the remote (Dev/Staging) database. To clean up the local history, a developer ran `pnpm supabase migration repair --status reverted` on 16+ migrations and then ran `pnpm supabase db push --include-all` against the dev/staging DB. | ||
|
|
||
| **Resulting State**: | ||
| - The schema effects of all migrations (from `202604300001` to `20260603100000`) were successfully applied (or already existed) on the Dev DB. | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| - However, the `schema_migrations` tracking table on the Dev DB had its rows removed by the `repair` command, resulting in Supabase CLI reporting them as "Unapplied" remotely. | ||
| - Furthermore, 6 old local mock schemas (`202601010000` through `202601010005`) were present in the migrations folder. These were superseded by `202604260001` which recreated all tables properly, meaning they were functionally present/replaced but historically unapplied. | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
| ### Pre-prod Reconciliation Steps Executed | ||
| To safely re-sync the history without breaking the functional dev schema, we executed the following steps: | ||
|
|
||
| 1. **Safety First**: Verified the linked ref was `hibfpvmxynoonzxxdllu` (Dev). | ||
| 2. **SQL Verification**: Checked directly via SQL that the schema effects for the unapplied migrations were physically present in the database (e.g. `idempotency_keys` table, `withdraw_wallet` function, `dispute_milestone` new auth logic). | ||
| 3. **Tracking Repair**: Looped through all 30 unapplied timestamps (the 6 early ones + the 24 recent ones) and ran `pnpm supabase migration repair --status applied <timestamp> --linked`. | ||
| - **Why the 6 early ones?**: If left unapplied, `pnpm supabase db push --dry-run` would attempt to apply them and fail since their objects (e.g., `profiles`) were already created by `202604260001`. Marking them as applied bypasses execution and ensures a 100% clean pending queue. | ||
| 4. **Clean Verification**: Ran `pnpm supabase migration list` and `db push --dry-run` to confirm exactly zero pending migrations. | ||
|
Comment on lines
+13
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical issue: fabricating migration history with Line 18 documents using While the rationale in line 19 is pragmatically sound (avoiding duplicate object errors from superseded migrations), the solution creates falsified migration tracking where Root cause analysis: The problem originated because:
Correct approach per ADR 0004:
The documented approach leaves the repository in a state where As per coding guidelines, ADR 0004 Rule 5 states: "The canonical apply path is the Supabase MCP apply_migration tool... The author is responsible for confirming the applied row matches the file on disk." 🤖 Prompt for AI Agents
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Acknowledged. This process absolutely deviated from the strict forward-only rules mandated by ADR-0004. I've added a new 'Deviation from ADR-0004' section to the document to explicitly clarify this. This was a one-time, dev/staging-only recovery to fix the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
A couple of small suggestions to make the deviation section as airtight as possible:
With those additions the document serves as a complete post-mortem. The concern is considered addressed given the explicit deviation documentation and the dev-only scope. 🐇 📋 |
||
|
|
||
| ### Deviation from ADR-0004 | ||
| - **Context:** ADR-0004 mandates forward-only, immutable migrations applied via `apply_migration`. This reconciliation deviated from that and is scoped strictly as a ONE-TIME, dev/staging-ONLY recovery. | ||
| - **What changed:** ONLY the `supabase_migrations.schema_migrations` tracking table was updated by the recovery steps (via `migration repair`). No migration files were edited, and no SQL was re-run *during the tracking recovery* (though the incident itself involved a `db push`), and production was never touched. | ||
| - **Why it was necessary:** An earlier `migration repair --status reverted` wiped tracking rows for migrations whose schema effects were already live, leaving `db push` unable to proceed. Repairing tracking to reflect reality was the minimal fix. | ||
| - **Precedent:** ADR-0004 remains fully in force for all future migrations. This runbook is explicitly NOT a precedent for rewriting PRODUCTION migration history. | ||
|
|
||
| ### Future Action (Pre-Launch Squash) | ||
| Before launching to production, we must squash and rename the local migrations to consolidate the numerous patches into a clean baseline sequence. This squash will cleanly combine the `202601010000` mock schemas and the fragmented PR #1/19/20 fixes into coherent numbered releases (e.g., Phase 1 Schema, Phase 2 Escrow). | ||
|
greptile-apps[bot] marked this conversation as resolved.
Comment on lines
+28
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical issue: planned squash/rename violates ADR 0004 forward-only principle. The proposed pre-launch squash to "consolidate the numerous patches into a clean baseline sequence" directly violates ADR 0004 Rule 1: "Never edit, rename, or delete an existing migration file after it has been applied to any environment." According to the reconciliation steps documented in line 18, all 30 migrations were marked as Impact: If these migrations are squashed:
Correct approach: Once migrations are marked as applied (even via
The combination of using As per coding guidelines, ADR 0004 Rule 1 states: "Migrations are append-only... Never edit, rename, or delete an existing migration file after it has been applied to any environment." 🤖 Prompt for AI Agents
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Acknowledged. This process absolutely deviated from the strict forward-only rules mandated by ADR-0004. I've added a new 'Deviation from ADR-0004' section to the document to explicitly clarify this. This was a one-time, dev/staging-only recovery to fix the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
A couple of notes:
If you update line 23 to reflect the no-squash commitment, this comment can be resolved. Would you also like to open a follow-up issue to track the "clean baseline migration" work as an append-only alternative to the squash? 🐇 (⌒‿⌒) — well documented recovery! |
||
| Additionally, we will normalize the mixed 12-/14-digit timestamp prefixes (e.g. `202604300001`) to the standard 14-digit `YYYYMMDDHHMMSS` format during this squash. | ||
Uh oh!
There was an error while loading. Please reload this page.