nextcloud / tables

🍱 Nextcloud tables app
https://apps.nextcloud.com/apps/tables
GNU Affero General Public License v3.0
143 stars 24 forks source link

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

Closed blizzz closed 4 months ago

blizzz commented 5 months ago

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.

blizzz commented 5 months ago

ftr: further read

Sylvain303 commented 4 months ago

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 commented 4 months ago

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.

Sylvain303 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

Repair steps takes both IDs now into account.

blizzz commented 4 months ago

/backport to stable0.7