Skip to content

fix(migrations): normalize retired share-link kinds and reconcile legacy schemas - #9

Closed
joshberen wants to merge 1 commit into
risunCode:devfrom
joshberen:fix/migration-legacy-reconcile
Closed

joshberen wants to merge 1 commit into
risunCode:devfrom
joshberen:fix/migration-legacy-reconcile

Conversation

@joshberen

@joshberen joshberen commented Oct 14, 2026 •

Copy link
Copy Markdown

Normalizes the retired share-link kinds before the kind constraint is replaced, and reconciles objects that a pre-rewrite database misses.

Verified by applying the migration chain to a copy of a deployed schema.

Closed by the author.

…acy schemas

Databases created from a pre-rewrite baseline cannot complete the migration
chain. 0006 rebuilds `share_links_kind_check` over rows that still hold the
retired `monitor`/`setup` kinds, so the check fails, the transaction rolls back,
and every later migration is left unapplied (35 of them as of 0040).

Rename those rows first (`monitor`→`enroll`, `setup`→`handoff`) and retire them,
matching the rule the backup importer already applies to the same legacy kinds
("import them as inactive enrollment links so their old tokens never regain a
usable public endpoint", `src/console/backup/validate.ts`): the rows were written
for the old page contract, and an old token must not start answering the new one.

Objects introduced by editing `0000_baseline.sql` itself reach no existing
database — the snapshot is already in the ledger, and no later file adds them.
A pre-rewrite database therefore finished the chain while still missing
`telemetry_usage_totals` and the share-key columns on `api_keys`
(`key_mode`, `parent_key_id`, `issued_client_ip`, `issued_client_ip_key`), then
failed its first key lookup with `column "key_mode" does not exist`.
`0041_reconcile_legacy_schema.sql` closes that gap idempotently.

Unused legacy objects (`backup_status`, `console_users.last_login_at`,
`telemetry_payloads.redaction_applied`, four superseded indexes) are left in
place: dropping them is destructive and not required to unblock the upgrade.

Verified against a production dump: chain completes (42 migrations), the
resulting schema matches a fresh database column-for-column, a live completion
succeeds, and data is preserved.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-14T04:31:49.909686Z a4daac4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-14T04:31:49.909686Z a4daac4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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