Skip to content

fix: align all serial sequences after SQLite import - #29

Open
johoja12 wants to merge 1 commit into
cgnl:mainfrom
johoja12:fix/align-all-imported-sequences
Open

johoja12 wants to merge 1 commit into
cgnl:mainfrom
johoja12:fix/align-all-imported-sequences

Conversation

@johoja12

Copy link
Copy Markdown

Problem

The SQLite-to-PostgreSQL importer advances only four serial sequences. Imported Plex data can contain much larger IDs in other tables. On our isolated QNAP migration of a real library, devices had 15,192 rows but devices_id_seq was still at 1. Plex's startup insert failed with a devices_pkey duplicate even though all 36 imported tables and 1,152 blobs were otherwise intact.

Fix

After the table import, enumerate every owned serial sequence in the target schema and set it to the corresponding table's maximum imported ID. Empty tables leave the next value at 1. A sequence alignment error now fails the migration instead of being silently ignored.

Verification

The same generalized SQL was applied to the isolated migrated PostgreSQL database. devices_id_seq became 15,192, matching max(devices.id), and Plex continued serving /identity and all eight library sections. Production Plex remains on SQLite while the canary is evaluated.

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.

1 participant