Skip to content

Schema workstream: 1.0 hygiene and migration reset (umbrella) #888

Open

Description

@Quick104

Part of the API v2 program epic #135. Durable architecture: docs/architecture/api-contract.md (PR #880). Runs in parallel with the API phases; everything below ships in or before the bridge except the reset itself.

Grouped deliverables:

  1. Dead-table drops — plex_sync_* ×4, user_playback_sessions, content_id_migration_map: PR chore(db): drop dead plex_sync, user_playback_sessions, and content_id_migration_map tables [schema-hygiene 1/4] #879.
  2. Integrity — the 14 missing user_id foreign keys (partitioned policy_decisions* may stay exempt), leading indexes for the 46 unindexed FK columns (prioritize auth_sessions.user_id, downloads.media_file_id, library_collection_items.media_item_id), users.role/users.enabled NOT NULL.
  3. Standardization — 36 serial-style tables to GENERATED AS IDENTITY; 14 varchar(n) columns in notifications/push to text; consistency renames (oauth_session, oauth_completion, playback_history_admin).
  4. Bigint widenings — users.id, media_files.id, media_folders.id: table rewrites; separate PR with an explicit maintenance-window release note.
  5. Bridge-timing — drop user_settings + user_setting_migration_rejects after the Go settings backfill; bridge is the last release with the one-way SQLite→Postgres userdb import.
  6. 1.0 reset — migration squash to one baseline + guard (empty or bridge-tip only), seed-data fidelity audit (~53 seeding migrations incl. backfill-completion flags), CI parity gate comparing normalized schema and seed data; the parity gate must exist before the baseline PR opens (Phase 6).

Blocked on maintainer decisions (do not implement until recorded on #135): which library-restriction layers survive (per-user library_ids, access-group list, per-profile allow list, profile-scoped setting), and whether the per-user policy override columns on users remain a documented override chain or fold into access groups.

Migration discipline is absolute per AGENTS.md gotchas: make migrate-create only, no goose fix, no paired up/down files, no renumbering, no encrypted server_settings renames.

AI disclosure: drafted by Claude Code (claude-fable-5) orchestrating the #135 program.

Activity

  1. Quick104 commented on Sep 1, 2026

    @Quick104
    ContributorAuthor

    Status: item 1 (dead-table drops) is PR #879; item 2 (integrity — 17 user FKs, 57 FK leading indexes, role/enabled NOT NULL) is PR #889, stacked on #879. Item 3 (standardization) starting next on a branch stacked on #889.

    Noted during the integrity audit for a later decision: jellycompat_playback_sessions.user_id and oauth_session.linking_user_id hold Silo user ids as text (the latter parsed with strconv.Atoi in internal/auth/oauth_handler.go), so they cannot carry FKs without a column retype — candidate for the standardization group or a follow-up, needs its own review.

    Posted by the #135 orchestration session (claude-fable-5 via Claude Code).

  2. Quick104 commented on Sep 1, 2026

    @Quick104
    ContributorAuthor

    Decision record (schema PR 3, #893): the table renames ship as a single-transaction rename without compatibility views or an expand/contract release pair. Rationale on the PR: mixed-version API replicas during a shape-changing migration are unsupported under the documented maintenance-window posture; the rename fails closed on old replicas; carrying views into the squashed 1.0 baseline works against this workstream. If the maintainer wants expand/contract for renames specifically, the restructure is Go-side dual-name support one release ahead of the rename.

    Also fixed on #889 (5bad725): the planstore DB-gated test fixture now supplies a role, since users.role is NOT NULL with no default after the integrity migration.

    Next in this workstream: PR 4 (bigint widenings of users.id / media_files.id / media_folders.id) is in progress on schema/hygiene-bigint-ids, stacked on #893.

    Posted by the #135 orchestration session (claude-fable-5 via Claude Code).

  3. Quick104 commented on Sep 1, 2026

    @Quick104
    ContributorAuthor

    Item 4 (bigint widenings of users.id, media_files.id, media_folders.id) is PR #898, stacked on #893. Parents only, per the plan; the migration header carries the full list of integer child columns with rewrite cost, plus four int4 advisory-lock sites, for the maintainer to schedule as a separate child sweep. The PR body has the maintenance-window release note (three tables rewritten, ACCESS EXCLUSIVE on every referencing relation, raise SILO_MIGRATE_TIMEOUT on large libraries).

    The pre-bridge hygiene stack is now complete: main ← #879 ← #889 ← #893 ← #898. Remaining in this workstream: the bridge-timing drop of user_settings/user_setting_migration_rejects (Phase 5), the 1.0 reset with parity gate (Phase 6), and the two design decisions above, which stay blocked on the maintainer.

    Posted by the #135 orchestration session (claude-fable-5 via Claude Code).

  4. added
    schema-1.0
    epic
    on Sep 1, 2026
  5. Quick104 commented on Sep 2, 2026

    @Quick104
    ContributorAuthor

    Follow-up filed: #906 — adopt sqlc for the static-query repositories once item 6 (the 1.0 baseline + parity gate) is on main. Deliberately sequenced after this workstream and outside the API v2 program; reasoning is in the issue.

  6. added
    triaged
    and removed
    triaged
    on Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    epicschema-1.0

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions