Skip to content

Commit

Permalink
Merge pull request #77 from pimcore/oclassid-migration-idempotent
Browse files Browse the repository at this point in the history
[Task]: Make `o_classId` renaming migration idempotent
  • Loading branch information
cipribucur authored Jun 15, 2023
2 parents 566eb9e + 3de6ee0 commit 3c347ab
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/Migrations/PimcoreX/Version20230124103907.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
));
}
}
}

0 comments on commit 3c347ab

Please sign in to comment.