mautrix / signal

A Matrix-Signal puppeting bridge
GNU Affero General Public License v3.0
484 stars 74 forks source link

Make sqlite-compatible migration step #477

Open AndrewFerr opened 3 months ago

AndrewFerr commented 3 months ago

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.

tulir commented 3 months ago

I thought EMS used Postgres 🤔

AndrewFerr commented 3 months ago

I thought EMS used Postgres 🤔

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

tulir commented 3 months ago

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

AndrewFerr commented 3 months ago

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.