Skip to content

Commit

Permalink
Merge pull request #207 from born05/craft-3
Browse files Browse the repository at this point in the history
Fixes #127 error.
  • Loading branch information
engram-design authored Oct 24, 2018
2 parents d26e2dd + b711b87 commit 923f5f8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/migrations/m180219_000000_sites.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ public function safeUp()

foreach ($this->db->getSchema()->getTableNames() as $tableName) {
if (StringHelper::startsWith($tableName, $superTableTablePrefix)) {
// Rename column
if ($this->db->columnExists($tableName, 'locale__siteId')) {
$this->renameColumn($tableName, 'locale__siteId', 'siteId');
}

// There's actually an issue here in the MigrationHelper::dropAllIndexesOnTable class, not using the current migration
// as context to find existing indexes. This is important, because the indexes have changed from their current names
$this->dropAllForeignKeysOnTable($tableName);
$this->dropAllIndexesOnTable($tableName);

// Rename column
if ($this->db->columnExists($tableName, 'locale__siteId')) {
$this->renameColumn($tableName, 'locale__siteId', 'siteId');
}

// Add them back (like creating a new Matrix would)
$this->createIndex(null, $tableName, ['elementId', 'siteId'], true);
$this->addForeignKey(null, $tableName, ['elementId'], '{{%elements}}', ['id'], 'CASCADE', null);
Expand Down

0 comments on commit 923f5f8

Please sign in to comment.