From 557347d42d9f71504fd43503dd9193d16c4f8682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 7 May 2023 21:43:01 +0200 Subject: [PATCH] Fixed legacy database migration for newer MySQL version --- migrations/Version20220925162725.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/migrations/Version20220925162725.php b/migrations/Version20220925162725.php index 52caa2a9..0f04f04e 100644 --- a/migrations/Version20220925162725.php +++ b/migrations/Version20220925162725.php @@ -71,7 +71,10 @@ final class Version20220925162725 extends AbstractMultiPlatformMigration // this up() migration is auto-generated, please modify it to your needs $this->addSql('CREATE INDEX attachment_types_idx_name ON attachment_types (name)'); $this->addSql('CREATE INDEX attachment_types_idx_parent_name ON attachment_types (parent_id, name)'); + //We have to disable foreign key checks here, or we get a error on MySQL for legacy database migration. On MariaDB this works fine (with enabled foreign key checks), so I guess this is not so bad... + $this->addSql('SET foreign_key_checks = 0'); $this->addSql('ALTER TABLE attachments CHANGE type_id type_id INT NOT NULL'); + $this->addSql('SET foreign_key_checks = 1'); $this->addSql('CREATE INDEX attachments_idx_id_element_id_class_name ON attachments (id, element_id, class_name)'); $this->addSql('CREATE INDEX attachments_idx_class_name_id ON attachments (class_name, id)'); $this->addSql('CREATE INDEX attachment_name_idx ON attachments (name)');