Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resynch database sequences after backup restore #85

Open
htmfilho opened this issue Sep 23, 2022 · 1 comment
Open

Resynch database sequences after backup restore #85

htmfilho opened this issue Sep 23, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@htmfilho
Copy link
Owner

Describe the bug

The implemented database backup is based on SQL scripts. It allows recovering the database without the application being up and running. However, it makes sequences get out of synch, causing issues with inserting new records due to primary-key conflicts.

To Reproduce

Steps to reproduce the behavior:

  1. Generate a backup file
  2. Create a new database and restore the backup
  3. Document a new table

Expected behavior

We expect sequences to be in sync with primary keys.

@htmfilho htmfilho added the bug Something isn't working label Sep 23, 2022
@htmfilho htmfilho self-assigned this Sep 23, 2022
@htmfilho
Copy link
Owner Author

htmfilho commented Sep 23, 2022

Implemented a solution that works in PostgreSQL, but not in H2. When we try to insert a new record and a primary key conflict happens, we increment the sequence in a recursive call until it doesn't conflict with the primary key anymore.

A solution for H2 is yet to be found. We may need to create the sequences manually or change the backup file from SQL to JSON.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant