You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
945 B

7 years ago
<?php
use yii\db\Migration;
/**
* Handles the creation of table `pages`.
*/
class m180107_210401_create_pages_table extends Migration
{
public function up()
{
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
$this->createTable('{{%pages}}', [
'id' => $this->primaryKey(),
'title' => $this->string()->notNull(),
'slug' => $this->string()->notNull(),
'content' => 'MEDIUMTEXT',
'meta_json' => $this->text()->notNull(),
'lft' => $this->integer()->notNull(),
'rgt' => $this->integer()->notNull(),
'depth' => $this->integer()->notNull(),
], $tableOptions);
$this->createIndex('{{%idx-pages-slug}}', '{{%pages}}', 'slug', true);
$this->insert('{{%pages}}', [
'id' => 1,
'title' => '',
'slug' => 'root',
'content' => null,
'meta_json' => '{}',
'lft' => 1,
'rgt' => 2,
'depth' => 0,
]);
}
public function down()
{
$this->dropTable('{{%pages}}');
}
}