Repository navigation
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e2f9e521a6
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| -- ALTER TABLE ... RENAME does not rename the indexes and constraints that were | ||
| -- named after the table, so each one is renamed explicitly; leaving them would | ||
| -- trade one inconsistency for a worse one. | ||
| ALTER TABLE public.oauth_session RENAME TO oauth_sessions; |
There was a problem hiding this comment.
Preserve old table names through rolling upgrades
In a multi-replica integrated/API deployment, the first new replica applies this rename while the old replicas are still serving, because cmd/silo/main.go runs migrations during each new primary replica's startup without stopping existing application traffic. Those old replicas continue issuing SQL against oauth_session, oauth_completion, and playback_history_admin, so new or uncached statements fail with relation does not exist; this breaks OAuth flows and can lose finalized playback-history writes for the rest of the rollout, rather than only during the brief migration lock. Keep compatibility views for the old names or perform the rename as an expand/contract change across releases.
AGENTS.md reference: AGENTS.md:L12-L17
Useful? React with 👍 / 👎.
…s, rename tables Converts 32 serial id columns to GENERATED BY DEFAULT AS IDENTITY with sequence continuity in both directions, widens the 14 varchar(n) columns in the notifications/push tables to text, and renames oauth_session, oauth_completion, and playback_history_admin to schema-consistent names. Co-Authored-By: Claude Fable 5 <[email protected]>
e2f9e52 to
87fdda6
Compare
|
Re the Codex P1 (preserve old table names through rolling upgrades): verified the mechanics — the first upgraded primary applies the rename at startup while any not-yet-upgraded replica keeps issuing SQL against the old names — and declining the compatibility-view/expand-contract approach with reasons, same as the drop migration in #879:
If the maintainer prefers expand/contract for renames specifically, the alternative is to ship the Go-side dual-name support one release before the rename; happy to restructure. Recorded on #888. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 87fdda6223
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ALTER TABLE public.oauth_session RENAME TO oauth_sessions; | ||
| ALTER INDEX public.oauth_session_pkey RENAME TO oauth_sessions_pkey; | ||
| ALTER INDEX public.oauth_session_expires_idx RENAME TO oauth_sessions_expires_idx; | ||
|
|
There was a problem hiding this comment.
Rename the primary-key constraints, not only their indexes
On PostgreSQL, ALTER INDEX ... RENAME changes the backing index name but leaves the associated primary-key constraint's pg_constraint.conname unchanged. After this migration, all three tables therefore retain old constraint names such as oauth_session_pkey, so later migrations referring to the expected oauth_sessions_pkey constraint will fail. Use ALTER TABLE ... RENAME CONSTRAINT in both directions; PostgreSQL will rename the backing index with it.
Useful? React with 👍 / 👎.
|
Re the Codex P2 (rename the primary-key constraints, not only their indexes): verified and dismissed as incorrect for PostgreSQL. And on the scratch database after this migration ran, |
|
Closing as superseded by the merged schema-hygiene replacement. |
Problem
Related issue: #135 (schema workstream: #888)
Before the 1.0 schema baseline freezes the shape of every table, three inconsistencies are still cheap to fix: 32 id columns use legacy
serialdefaults while 20 newer tables already use identity columns; the notifications/push tables carry 14varchar(n)columns whose limits the application already enforces (and duplicates) in Go; and three tables break the schema's naming convention (oauth_session,oauth_completionsingular in a plural schema;playback_history_adminputs the scope qualifier last where every sibling —admin_jobs,admin_dashboard_layouts,user_watch_history— puts it first).Base branch:
schema/hygiene-integrity(PR #889) — third PR in the schema-hygiene stack; only the top commit is new here.Approach
Three migrations, lists derived empirically from a migrated scratch database (audit queries in the migration comments):
20260901180714_serial_ids_to_identity.sql— converts the 32 serialidcolumns (36 with the fouractivity_logpartitions that inherit) toGENERATED BY DEFAULT AS IDENTITY.BY DEFAULTkeeps serial parity: explicit-id inserts (used by tests and id-carrying restores) keep working. One DO loop handles every table through a single code path: lock viaDROP DEFAULT, read the old sequence position, drop it, add identity,setvalthe new sequence — so no table can restart at 1. The Down mirrors it (recreating the sequenceAS <column type>) and takes an explicitACCESS EXCLUSIVElock before reading the position.20260901180715_notification_varchar_to_text.sql— the 14varchar(n)columns totext; metadata-only (relfilenodes verified unchanged). Every length rule survives in Go (validateChannelName≤64, device_id ≤128,left($n, 256)on failure messages, etc.); no code depends on SQLSTATE 22001.20260901180726_rename_tables_for_consistency.sql—oauth_session → oauth_sessions,oauth_completion → oauth_completions,playback_history_admin → admin_playback_history, with every index/constraint renamed and a catalog-driven sweep for the named NOT NULL constraints Postgres 18 leaves behind onRENAME TABLE(no-op on older servers). All Go, test, and doc references updated; repo-wide grep clean.Encryption safety of the renames (checked before any rename stood):
secret.RowAADhas no call site on these tables;oauth_completion.token_ciphertextderives its key from a fixed label and usescode_hashas AAD — no table identifier anywhere. Proven by a survival test: a token encrypted intooauth_completiondecrypts through the realGetAndDeleteCompletionpath after the rename.Frozen-v1 wire check: the touched web widget and
docs/admin-api.mdedits are comment/prose only; no JSON field, query parameter, or TS type carried the old table name. No/api/v1wire change.migrations/schema_standardization_test.gopins the 32-table list in both directions, theBY DEFAULTchoice, the ordered continuity steps, the 14 columns with their restore lengths, the rename pairs with every index/constraint rename, and the NOT NULL sweep — mutation-tested (20 mutations, all caught).Validation
migrate-down-to 20260901161702then re-up clean; each migration cycled down/up individually;goose validateclean.users(with a deleted-row gap),media_files,activity_log,task_triggers,stream_nodes, plus advanced-but-empty sequences and an uncalled one; the 46-sequence snapshot was byte-identical across Up and Down; post-Up/post-Down/re-Up inserts continued without collision. Independently reproduced by the destructive-safety reviewer.make embed-stub,go build ./...,gofmt(empty),go vet: pass.golangci-lint run --new-from-merge-base="origin/main": 0 issues.make test-go: all ok. Web:pnpm run lint,format:check,build,make test-web: pass.make verify-settings-bindings-all,verify-playback-fixtures,verify-local-paths: pass.SILO_TEST_DATABASE_URLon the scratch DB:internal/auth,internal/catalog/reattribute,internal/metadata,internal/api,internal/api/handlers: pass.Risks
ACCESS EXCLUSIVEper table for a catalog-only change (no rewrite); brief, but it is a maintenance-window migration like the rest of the stack.internal/notificationspush-device tests (their TEMP shadow table lacksfcm_token_ciphertext) andinternal/catalogTestEpisodeSearchPostgresAndDocumentSource. Both reproduce at the base commit.Checklist
AI Disclosure