php-censor/src/Migrations/20170103163312_added_language_and_per_page_for_user.php
2018-03-09 13:46:18 +07:00

41 lines
912 B
PHP

<?php
use Phinx\Migration\AbstractMigration;
class AddedLanguageAndPerPageForUser extends AbstractMigration
{
public function up()
{
$table = $this->table('user');
if (!$table->hasColumn('language')) {
$table
->addColumn('language', 'string', ['limit' => 5, 'null' => true])
->save();
}
if (!$table->hasColumn('per_page')) {
$table
->addColumn('per_page', 'integer', ['null' => true])
->save();
}
}
public function down()
{
$table = $this->table('user');
if ($table->hasColumn('language')) {
$table
->removeColumn('language')
->save();
}
if ($table->hasColumn('per_page')) {
$table
->removeColumn('per_page')
->save();
}
}
}