signal icon indicating copy to clipboard operation
signal copied to clipboard

Make sqlite-compatible migration step

Open AndrewFerr opened this issue 1 year ago • 4 comments

The schema upgrade added in #464 uses ALTER COLUMN, so it's incompatible with SQLite.

This PR uses the same strategy as the v16 & v17 upgrades for the main store to add a SQLite-compatible version of this migration.

AndrewFerr avatar Mar 12 '24 14:03 AndrewFerr

I thought EMS used Postgres 🤔

tulir avatar Mar 12 '24 14:03 tulir

I thought EMS used Postgres 🤔

It does, but my local dev environment does not :slightly_smiling_face:

AndrewFerr avatar Mar 12 '24 14:03 AndrewFerr

You could just manually fix it :P The v7 -> v8 migration is exclusively for users of your PR, the main branch jumped from v6 to v8 and the alter tables there are already scoped to postgres only (because they're less important).

Anyway, if you really want sqlite support for that migration: there are no foreign keys referencing signalmeow_contacts, so disabling foreign keys and transactions isn't necessary and therefore a normal dialect-split upgrade works perfectly fine. The way to do that is to have two files with the same name and header comment, but one file name ending in .sqlite.sql and the other in .postgres.sql. https://github.com/mautrix/discord/blob/main/database/upgrades/13-merge-emoji-and-file.sqlite.sql + https://github.com/mautrix/discord/blob/main/database/upgrades/13-merge-emoji-and-file.postgres.sql is an example of that

tulir avatar Mar 12 '24 14:03 tulir

Thanks for the tips! I wasn't aware of the file-extension-based dialect splitting. Part of my reasoning in writing this PR is to learn the "proper" way to do mautrix schema upgrades, so this is a good outcome.

AndrewFerr avatar Mar 12 '24 15:03 AndrewFerr