fix: reset ID sequences after data import - #52
Merged
Conversation
…manual ID imports
When importing data with explicit IDs, the backing sequences were not advanced, causing future auto-generated IDs to collide with the imported ones. The import pipeline now synchronizes each affected sequence to the maximum imported ID after staging is complete.
Ryan2486
approved these changes
Feb 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request implements robust handling and synchronization of database sequences after importing data with explicit primary key values, ensuring that auto-generated IDs do not collide with manually imported ones. It introduces a mechanism to track the maximum imported ID per entity during import, updates the sequence accordingly, and adds integration tests to guarantee sequence integrity for all importable entities.
Sequence synchronization and tracking:
getMaxImportedId()to theEntityTableAdapterinterface and implemented logic inAbstractEntityTableAdapterto track the highest primary key value seen during each import batch. Each concrete adapter now provides anextractId()implementation to extract the ID from DTOs.Database migration:
V9__fix_sequence_values.sql) to retroactively fix sequence values for all relevant tables, ensuring their sequences are set to at least the current maximum ID.Testing and validation:
ImportSequenceIntegrityTest) that verifies, for all entity adapters, that after import the sequence is always ahead of or equal to the maximum primary key in the table, preventing duplicate key violations. This includes dynamic tests for all adapters and validation of test data presence.Minor improvements: