Alexander Kartavenko
5 years ago
committed by
Alexander Makarov
6 changed files with 118 additions and 3 deletions
@ -0,0 +1,37 @@
|
||||
<?php |
||||
/** |
||||
* @link http://www.yiiframework.com/ |
||||
* @copyright Copyright (c) 2008 Yii Software LLC |
||||
* @license http://www.yiiframework.com/license/ |
||||
*/ |
||||
|
||||
return <<<CODE |
||||
<?php |
||||
|
||||
use yii\db\Migration; |
||||
|
||||
/** |
||||
* Handles adding field_1, field_2 to table `{{%{table}}}`. |
||||
*/ |
||||
class {$class} extends Migration |
||||
{ |
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function safeUp() |
||||
{ |
||||
\$this->addColumn('{{%{table}}}', 'field_1', \$this->string(10)->notNull()); |
||||
\$this->addColumn('{{%{table}}}', 'field_2', \$this->text()->notNull()); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function safeDown() |
||||
{ |
||||
\$this->dropColumn('{{%{table}}}', 'field_1'); |
||||
\$this->dropColumn('{{%{table}}}', 'field_2'); |
||||
} |
||||
} |
||||
|
||||
CODE; |
@ -0,0 +1,39 @@
|
||||
<?php |
||||
/** |
||||
* @link http://www.yiiframework.com/ |
||||
* @copyright Copyright (c) 2008 Yii Software LLC |
||||
* @license http://www.yiiframework.com/license/ |
||||
*/ |
||||
|
||||
return <<<CODE |
||||
<?php |
||||
|
||||
use yii\db\Migration; |
||||
|
||||
/** |
||||
* Handles the creation of table `{{%test}}`. |
||||
*/ |
||||
class {$class} extends Migration |
||||
{ |
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function safeUp() |
||||
{ |
||||
\$this->createTable('{{%test}}', [ |
||||
'id' => \$this->primaryKey(), |
||||
'field_1' => \$this->dateTime()->notNull()->defaultValue('0000-00-00 00:00:00'), |
||||
'field_2' => \$this->string()->defaultValue('default:value'), |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function safeDown() |
||||
{ |
||||
\$this->dropTable('{{%test}}'); |
||||
} |
||||
} |
||||
|
||||
CODE; |
Loading…
Reference in new issue