php-censor/src/Migrations/20151009100610_remove_unique_name_index.php

20 lines
399 B
PHP
Raw Normal View History

2015-10-09 12:10:14 +02:00
<?php
use Phinx\Migration\AbstractMigration;
class RemoveUniqueNameIndex extends AbstractMigration
{
2016-05-07 08:43:21 +02:00
public function up()
2015-10-09 12:10:14 +02:00
{
$user = $this->table('user');
if ($user->hasIndex('name')) {
$user->removeIndex(['name'])->save();
2015-10-09 12:10:14 +02:00
}
if (!$user->hasIndex('name')) {
2017-01-29 03:49:43 +01:00
$user->addIndex(['name'], ['unique' => false])->save();
2016-05-05 18:33:12 +02:00
}
2015-10-09 12:10:14 +02:00
}
}