Skip to content

Commit

Permalink
upgrade: make sure scope exists
Browse files Browse the repository at this point in the history
  • Loading branch information
wellingguzman committed Dec 17, 2018
1 parent 6204ade commit 831d112
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions migrations/upgrades/schemas/20181123171520_remove_scope.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@ class RemoveScope extends AbstractMigration
public function up()
{
$table = $this->table('directus_settings');
$table->removeIndexByName('idx_scope_name');
$table->removeColumn('scope')
->save();
$table->addIndex(['key'], [
'unique' => true,
'name' => 'idx_key'
]);

if ($table->hasColumn('scope')) {
$oldIndexName = 'idx_scope_name';
// NOTE: Update to a more recent version of Phinx
// It implements the $table->hasIndexByName($oldIndexName);
if ($table->getAdapter()->hasIndexByName($table->getName(), $oldIndexName)) {
$table->removeIndexByName($oldIndexName);
}

$table->removeColumn('scope')
->save();
$table->addIndex(['key'], [
'unique' => true,
'name' => 'idx_key'
]);
}
}
}

0 comments on commit 831d112

Please sign in to comment.