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

fix(DB): update tables_row_sleeves' sequence after migration #1049

Merged
merged 1 commit into from
May 6, 2024

Conversation

blizzz
Copy link
Member

@blizzz blizzz commented May 3, 2024

fixes #1029

On (at least) Postgres the migration logic from 0.6.6 to 0.7 inserts rows into oc_tables_row_sleeves with the id parameter set. It is an autoincrement column, but when the ids are specified manually, the backing sequence is not updated automatically. It then leads to constraint violation when adding new rows.

Doctrine does not offer much to interact with sequences, so here is a fall back a manual query that follows SQL standard.

@Sylvain303
Copy link

I would say no, it wont fix #1029 given my last comment and rows that are left in the oc_tables_rows or would it suffice?

I mean given I deleted the Tables (from UI interface), but the rows are kept in oc_tables_rows, but the select max(id) from oc_tables_row_sleeves; may have caught the correct max(id) , if I wouldn't have deleted the Tables before... 🤔

@blizzz
Copy link
Member Author

blizzz commented May 6, 2024

I would say no, it wont fix #1029 given my last comment and rows that are left in the oc_tables_rows or would it suffice?

I mean given I deleted the Tables (from UI interface), but the rows are kept in oc_tables_rows, but the select max(id) from oc_tables_row_sleeves; may have caught the correct max(id) , if I wouldn't have deleted the Tables before... 🤔

That's great input! I'd read then both table's IDs and take the max value.

@blizzz blizzz added 2. developing Work in progress and removed 3. to review Waiting for reviews labels May 6, 2024
@Sylvain303
Copy link

That's great input! I'd read then both table's IDs and take the max value.

May you should also figure out why rows of deleted Tables are left in oc_tables_rows too?
If it's reproducible...

may occ maintenance:repair or occ tables:repair (⬅️ command doesn't exist actually) or such should cleanup something here. 🤷‍♀️

@blizzz
Copy link
Member Author

blizzz commented May 6, 2024

May you should also figure out why rows of deleted Tables are left in oc_tables_rows too?
If it's reproducible...

Definitely, but would separate it from this context.

@blizzz
Copy link
Member Author

blizzz commented May 6, 2024

May you should also figure out why rows of deleted Tables are left in oc_tables_rows too?
If it's reproducible...

Definitely, but would separate it from this context.

So that is, because oc_tables_rows is a legacy table and not in further use. It is kept only as a safety measure around the migration, for instance to be able to re-trigger the transfer to the modernized DB structure.

@blizzz
Copy link
Member Author

blizzz commented May 6, 2024

Repair steps takes both IDs now into account.

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
@blizzz
Copy link
Member Author

blizzz commented May 6, 2024

/backport to stable0.7

@backportbot backportbot bot added the backport-request Pending backport by the backport-bot label May 6, 2024
@blizzz blizzz merged commit 9c9a491 into main May 6, 2024
58 checks passed
@blizzz blizzz deleted the fix/1029/pgsql-seq branch May 6, 2024 13:30
@backportbot backportbot bot removed the backport-request Pending backport by the backport-bot label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API Insert row into a table duplicate key value violates unique constraint "oc_tables_row_sleeves_pkey"
3 participants