From ff892d983cb894789576c81e96f870a76f795f02 Mon Sep 17 00:00:00 2001 From: JiaJia Ji Date: Thu, 15 Jun 2023 14:40:19 +0200 Subject: [PATCH 1/3] make o_classId rename migration idempotent --- .../PimcoreX/Version20230124103907.php | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Migrations/PimcoreX/Version20230124103907.php b/src/Migrations/PimcoreX/Version20230124103907.php index 63f6e29..64e3e58 100644 --- a/src/Migrations/PimcoreX/Version20230124103907.php +++ b/src/Migrations/PimcoreX/Version20230124103907.php @@ -35,23 +35,27 @@ public function up(Schema $schema): void { $table = $schema->getTable(Dao::TABLE_NAME); - $this->addSql(sprintf( - 'ALTER TABLE `%s` RENAME COLUMN `%s` TO `%s`', - $table->getName(), - 'o_classId', - 'classId' - )); + if ($table->hasColumn('o_classid')) { + $this->addSql(sprintf( + 'ALTER TABLE `%s` RENAME COLUMN `%s` TO `%s`', + $table->getName(), + 'o_classId', + 'classId' + )); + } } public function down(Schema $schema): void { $table = $schema->getTable(Dao::TABLE_NAME); - - $this->addSql(sprintf( - 'ALTER TABLE `%s` RENAME COLUMN `%s` TO `%s`', - $table->getName(), - 'classId', - 'o_classId' - )); + + if ($table->hasColumn('classid')) { + $this->addSql(sprintf( + 'ALTER TABLE `%s` RENAME COLUMN `%s` TO `%s`', + $table->getName(), + 'classId', + 'o_classId' + )); + } } } From c8eb9c39f6d9ffdb0889b1c062e57cc5a05d0834 Mon Sep 17 00:00:00 2001 From: kingjia90 Date: Thu, 15 Jun 2023 12:40:36 +0000 Subject: [PATCH 2/3] Apply php-cs-fixer changes --- src/Migrations/PimcoreX/Version20230124103907.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Migrations/PimcoreX/Version20230124103907.php b/src/Migrations/PimcoreX/Version20230124103907.php index 64e3e58..b286075 100644 --- a/src/Migrations/PimcoreX/Version20230124103907.php +++ b/src/Migrations/PimcoreX/Version20230124103907.php @@ -48,7 +48,7 @@ public function up(Schema $schema): void public function down(Schema $schema): void { $table = $schema->getTable(Dao::TABLE_NAME); - + if ($table->hasColumn('classid')) { $this->addSql(sprintf( 'ALTER TABLE `%s` RENAME COLUMN `%s` TO `%s`', From 3de6ee025f89c0cee81d001f90092d4a93502549 Mon Sep 17 00:00:00 2001 From: JiaJia Ji Date: Thu, 15 Jun 2023 14:43:19 +0200 Subject: [PATCH 3/3] fix typo caps --- src/Migrations/PimcoreX/Version20230124103907.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Migrations/PimcoreX/Version20230124103907.php b/src/Migrations/PimcoreX/Version20230124103907.php index b286075..e4a4e9c 100644 --- a/src/Migrations/PimcoreX/Version20230124103907.php +++ b/src/Migrations/PimcoreX/Version20230124103907.php @@ -35,7 +35,7 @@ public function up(Schema $schema): void { $table = $schema->getTable(Dao::TABLE_NAME); - if ($table->hasColumn('o_classid')) { + if ($table->hasColumn('o_classId')) { $this->addSql(sprintf( 'ALTER TABLE `%s` RENAME COLUMN `%s` TO `%s`', $table->getName(), @@ -49,7 +49,7 @@ public function down(Schema $schema): void { $table = $schema->getTable(Dao::TABLE_NAME); - if ($table->hasColumn('classid')) { + if ($table->hasColumn('classId')) { $this->addSql(sprintf( 'ALTER TABLE `%s` RENAME COLUMN `%s` TO `%s`', $table->getName(),