diff --git a/migrations/mysql/2026-09-02-120000_add_indexes/down.sql b/migrations/mysql/2026-09-02-120000_add_indexes/down.sql index 22eca210..e51c9fc5 100644 --- a/migrations/mysql/2026-09-02-120000_add_indexes/down.sql +++ b/migrations/mysql/2026-09-02-120000_add_indexes/down.sql @@ -1,3 +1,7 @@ +-- On MariaDB these indexes back the foreign keys created from the inline REFERENCES, +-- and dropping them is refused with error 1553 while the constraints are enforced. +SET FOREIGN_KEY_CHECKS = 0; + DROP INDEX idx_ciphers_user_uuid ON ciphers; DROP INDEX idx_ciphers_organization_uuid ON ciphers; DROP INDEX idx_attachments_cipher_uuid ON attachments; diff --git a/migrations/mysql/2026-09-02-120000_add_indexes/up.sql b/migrations/mysql/2026-09-02-120000_add_indexes/up.sql index 412bf96c..a1407960 100644 --- a/migrations/mysql/2026-09-02-120000_add_indexes/up.sql +++ b/migrations/mysql/2026-09-02-120000_add_indexes/up.sql @@ -1,6 +1,10 @@ --- archives.cipher_uuid is left out: it is declared as an explicit FOREIGN KEY, --- so InnoDB already maintains an index for it. Every other table below uses --- inline REFERENCES, which MySQL parses and ignores, so no index exists. +-- archives.cipher_uuid is left out: it is declared as an explicit FOREIGN KEY, so both +-- MySQL and MariaDB already maintain an index for it. +-- +-- Every other table below uses inline REFERENCES. MySQL parses and ignores those, so no +-- index exists there. MariaDB honours them and backs each one with an auto-named index, +-- which InnoDB drops once the named index below can serve the constraint. Both engines +-- therefore end up with exactly one index per column. CREATE INDEX idx_ciphers_user_uuid ON ciphers (user_uuid); CREATE INDEX idx_ciphers_organization_uuid ON ciphers (organization_uuid); CREATE INDEX idx_attachments_cipher_uuid ON attachments (cipher_uuid);