From 3edaed78792796a52f28c797932c7792d522e2c4 Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Sun, 18 Feb 2024 23:47:34 +0100 Subject: [PATCH] Make migrations noop instead of skipping --- app/DoctrineMigrations/Version20161001072726.php | 6 +++++- app/DoctrineMigrations/Version20161022134138.php | 12 ++++++++++-- app/DoctrineMigrations/Version20170510082609.php | 12 ++++++++++-- app/DoctrineMigrations/Version20170719231144.php | 6 +++++- app/DoctrineMigrations/Version20171008195606.php | 12 ++++++++++-- app/DoctrineMigrations/Version20181128203230.php | 12 ++++++++++-- app/DoctrineMigrations/Version20190511165128.php | 12 ++++++++++-- app/DoctrineMigrations/Version20190619093534.php | 12 ++++++++++-- 8 files changed, 70 insertions(+), 14 deletions(-) diff --git a/app/DoctrineMigrations/Version20161001072726.php b/app/DoctrineMigrations/Version20161001072726.php index d87bc6b18..bb15a420c 100644 --- a/app/DoctrineMigrations/Version20161001072726.php +++ b/app/DoctrineMigrations/Version20161001072726.php @@ -18,7 +18,11 @@ class Version20161001072726 extends WallabagMigration { $platform = $this->connection->getDatabasePlatform(); - $this->skipIf($platform instanceof SqlitePlatform, 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.'); + if ($platform instanceof SqlitePlatform) { + $this->write('Migration can only be executed safely on \'mysql\' or \'postgresql\'.'); + + return; + } // remove all FK from entry_tag switch (true) { diff --git a/app/DoctrineMigrations/Version20161022134138.php b/app/DoctrineMigrations/Version20161022134138.php index 8f47f7166..ee494b334 100644 --- a/app/DoctrineMigrations/Version20161022134138.php +++ b/app/DoctrineMigrations/Version20161022134138.php @@ -13,7 +13,11 @@ class Version20161022134138 extends WallabagMigration { public function up(Schema $schema): void { - $this->skipIf(!$this->connection->getDatabasePlatform() instanceof MySQLPlatform, 'This migration only apply to MySQL'); + if (!$this->connection->getDatabasePlatform() instanceof MySQLPlatform) { + $this->write('This migration only apply to MySQL'); + + return; + } $this->addSql('ALTER DATABASE `' . $this->connection->getParams()['dbname'] . '` CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;'); @@ -41,7 +45,11 @@ class Version20161022134138 extends WallabagMigration public function down(Schema $schema): void { - $this->skipIf(!$this->connection->getDatabasePlatform() instanceof MySQLPlatform, 'This migration only apply to MySQL'); + if (!$this->connection->getDatabasePlatform() instanceof MySQLPlatform) { + $this->write('This migration only apply to MySQL'); + + return; + } $this->addSql('ALTER DATABASE `' . $this->connection->getParams()['dbname'] . '` CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;'); diff --git a/app/DoctrineMigrations/Version20170510082609.php b/app/DoctrineMigrations/Version20170510082609.php index 5210d9a47..aa09ff9f6 100644 --- a/app/DoctrineMigrations/Version20170510082609.php +++ b/app/DoctrineMigrations/Version20170510082609.php @@ -20,7 +20,11 @@ class Version20170510082609 extends WallabagMigration public function up(Schema $schema): void { - $this->skipIf(!$this->connection->getDatabasePlatform() instanceof MySQLPlatform, 'This migration only apply to MySQL'); + if (!$this->connection->getDatabasePlatform() instanceof MySQLPlatform) { + $this->write('This migration only apply to MySQL'); + + return; + } foreach ($this->fields as $field) { $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE ' . $field . ' ' . $field . ' VARCHAR(180) NOT NULL;'); @@ -29,7 +33,11 @@ class Version20170510082609 extends WallabagMigration public function down(Schema $schema): void { - $this->skipIf(!$this->connection->getDatabasePlatform() instanceof MySQLPlatform, 'This migration only apply to MySQL'); + if (!$this->connection->getDatabasePlatform() instanceof MySQLPlatform) { + $this->write('This migration only apply to MySQL'); + + return; + } foreach ($this->fields as $field) { $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE ' . $field . ' ' . $field . ' VARCHAR(255) NOT NULL;'); diff --git a/app/DoctrineMigrations/Version20170719231144.php b/app/DoctrineMigrations/Version20170719231144.php index 9fda3ac8d..f47cf9b24 100644 --- a/app/DoctrineMigrations/Version20170719231144.php +++ b/app/DoctrineMigrations/Version20170719231144.php @@ -13,7 +13,11 @@ class Version20170719231144 extends WallabagMigration { public function up(Schema $schema): void { - $this->skipIf($this->connection->getDatabasePlatform() instanceof SqlitePlatform, 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.'); + if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) { + $this->write('Migration can only be executed safely on \'mysql\' or \'postgresql\'.'); + + return; + } // Find tags which need to be merged $dupTags = $this->connection->query(' diff --git a/app/DoctrineMigrations/Version20171008195606.php b/app/DoctrineMigrations/Version20171008195606.php index 4a4235f55..2d348c877 100644 --- a/app/DoctrineMigrations/Version20171008195606.php +++ b/app/DoctrineMigrations/Version20171008195606.php @@ -17,7 +17,11 @@ class Version20171008195606 extends WallabagMigration { $platform = $this->connection->getDatabasePlatform(); - $this->skipIf($platform instanceof SqlitePlatform, 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.'); + if ($platform instanceof SqlitePlatform) { + $this->write('Migration can only be executed safely on \'mysql\' or \'postgresql\'.'); + + return; + } switch (true) { case $platform instanceof MySQLPlatform: @@ -35,7 +39,11 @@ class Version20171008195606 extends WallabagMigration { $platform = $this->connection->getDatabasePlatform(); - $this->skipIf($platform instanceof SqlitePlatform, 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.'); + if ($platform instanceof SqlitePlatform) { + $this->write('Migration can only be executed safely on \'mysql\' or \'postgresql\'.'); + + return; + } switch (true) { case $platform instanceof MySQLPlatform: diff --git a/app/DoctrineMigrations/Version20181128203230.php b/app/DoctrineMigrations/Version20181128203230.php index 165831316..a384ba118 100644 --- a/app/DoctrineMigrations/Version20181128203230.php +++ b/app/DoctrineMigrations/Version20181128203230.php @@ -13,7 +13,11 @@ class Version20181128203230 extends WallabagMigration { public function up(Schema $schema): void { - $this->skipIf(!$this->connection->getDatabasePlatform() instanceof MySQLPlatform, 'This migration can only be applied on \'mysql\'.'); + if (!$this->connection->getDatabasePlatform() instanceof MySQLPlatform) { + $this->write('This migration can only be applied on \'mysql\'.'); + + return; + } $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_access_tokens') . ' CHANGE `token` `token` varchar(191) NOT NULL'); $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_access_tokens') . ' CHANGE `scope` `scope` varchar(191)'); @@ -28,7 +32,11 @@ class Version20181128203230 extends WallabagMigration public function down(Schema $schema): void { - $this->skipIf(!$this->connection->getDatabasePlatform() instanceof MySQLPlatform, 'This migration can only be applied on \'mysql\'.'); + if (!$this->connection->getDatabasePlatform() instanceof MySQLPlatform) { + $this->write('This migration can only be applied on \'mysql\'.'); + + return; + } $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_access_tokens') . ' CHANGE `token` `token` varchar(255) NOT NULL'); $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_access_tokens') . ' CHANGE `scope` `scope` varchar(255)'); diff --git a/app/DoctrineMigrations/Version20190511165128.php b/app/DoctrineMigrations/Version20190511165128.php index 9c532b38d..35b76300f 100644 --- a/app/DoctrineMigrations/Version20190511165128.php +++ b/app/DoctrineMigrations/Version20190511165128.php @@ -15,7 +15,11 @@ final class Version20190511165128 extends WallabagMigration { public function up(Schema $schema): void { - $this->skipIf(!$this->connection->getDatabasePlatform() instanceof MySQLPlatform, 'This migration only apply to MySQL'); + if (!$this->connection->getDatabasePlatform() instanceof MySQLPlatform) { + $this->write('This migration only apply to MySQL'); + + return; + } $this->addSql('ALTER TABLE ' . $this->getTable('tag') . ' CHANGE `label` `label` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;'); $this->addSql('ALTER TABLE ' . $this->getTable('tag') . ' CHANGE `slug` `slug` VARCHAR(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;'); @@ -23,7 +27,11 @@ final class Version20190511165128 extends WallabagMigration public function down(Schema $schema): void { - $this->skipIf(!$this->connection->getDatabasePlatform() instanceof MySQLPlatform, 'This migration only apply to MySQL'); + if (!$this->connection->getDatabasePlatform() instanceof MySQLPlatform) { + $this->write('This migration only apply to MySQL'); + + return; + } $this->addSql('ALTER TABLE ' . $this->getTable('tag') . ' CHANGE `slug` `slug` VARCHAR(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); $this->addSql('ALTER TABLE ' . $this->getTable('tag') . ' CHANGE `label` `label` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); diff --git a/app/DoctrineMigrations/Version20190619093534.php b/app/DoctrineMigrations/Version20190619093534.php index ecc295370..ae1ad8a0b 100644 --- a/app/DoctrineMigrations/Version20190619093534.php +++ b/app/DoctrineMigrations/Version20190619093534.php @@ -15,7 +15,11 @@ final class Version20190619093534 extends WallabagMigration public function up(Schema $schema): void { // this up() migration is auto-generated, please modify it to your needs - $this->skipIf(!$this->connection->getDatabasePlatform() instanceof SqlitePlatform, 'Migration can only be executed safely on \'sqlite\'.'); + if (!$this->connection->getDatabasePlatform() instanceof SqlitePlatform) { + $this->write('Migration can only be executed safely on \'sqlite\'.'); + + return; + } $this->addSql('UPDATE ' . $this->getTable('entry', true) . ' SET reading_time = 0 WHERE reading_time IS NULL;'); @@ -43,7 +47,11 @@ final class Version20190619093534 extends WallabagMigration public function down(Schema $schema): void { // this down() migration is auto-generated, please modify it to your needs - $this->skipIf(!$this->connection->getDatabasePlatform() instanceof SqlitePlatform, 'Migration can only be executed safely on \'sqlite\'.'); + if (!$this->connection->getDatabasePlatform() instanceof SqlitePlatform) { + $this->write('Migration can only be executed safely on \'sqlite\'.'); + + return; + } $this->addSql('DROP INDEX IDX_F4D18282A76ED395'); $this->addSql('DROP INDEX created_at');