Added 'user_id' (created by) and 'create_date' columns to 'project_group' table.
This commit is contained in:
parent
4ec6d854c2
commit
7382df7f6d
5 changed files with 131 additions and 20 deletions
|
|
@ -14,8 +14,6 @@ class AddedAdditionalColumns extends AbstractMigration
|
|||
->save();
|
||||
}
|
||||
|
||||
$table = $this->table('build');
|
||||
|
||||
if ($table->hasColumn('created')) {
|
||||
$table
|
||||
->renameColumn('created', 'create_date')
|
||||
|
|
@ -45,8 +43,6 @@ class AddedAdditionalColumns extends AbstractMigration
|
|||
->save();
|
||||
}
|
||||
|
||||
$table = $this->table('build');
|
||||
|
||||
if ($table->hasColumn('create_date')) {
|
||||
$table
|
||||
->renameColumn('create_date', 'created')
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
class AddedAdditionalColumns2 extends AbstractMigration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$table = $this->table('project_group');
|
||||
|
||||
if (!$table->hasColumn('create_date')) {
|
||||
$table
|
||||
->addColumn('create_date', 'datetime', ['null' => true])
|
||||
->save();
|
||||
}
|
||||
|
||||
if (!$table->hasColumn('user_id')) {
|
||||
$table
|
||||
->addColumn('user_id', 'integer', ['default' => 0])
|
||||
->save();
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$table = $this->table('project_group');
|
||||
|
||||
if ($table->hasColumn('create_date')) {
|
||||
$table
|
||||
->removeColumn('create_date')
|
||||
->save();
|
||||
}
|
||||
|
||||
if ($table->hasColumn('user_id')) {
|
||||
$table
|
||||
->removeColumn('user_id')
|
||||
->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue