12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- use yii\db\Schema;
- use yii\db\Migration;
- class m231118_081037_docs extends Migration
- {
- public function init()
- {
- $this->db = 'db';
- parent::init();
- }
- public function safeUp()
- {
- $tableOptions = 'ENGINE=InnoDB';
- $this->createTable(
- '{{%docs}}',
- [
- 'id'=> $this->primaryKey()->unsigned(),
- 'title'=> $this->text()->notNull()->comment('Заголовок'),
- 'text'=> $this->text()->notNull()->comment('Описание'),
- 'cat'=> $this->string(128)->null()->defaultValue(null),
- 'uid'=> $this->string(128)->notNull(),
- ],$tableOptions
- );
- $this->createIndex('uid','{{%docs}}',['uid'],false);
- $this->createIndex('cat','{{%docs}}',['cat'],false);
- }
- public function safeDown()
- {
- $this->dropIndex('uid', '{{%docs}}');
- $this->dropIndex('cat', '{{%docs}}');
- $this->dropTable('{{%docs}}');
- }
- }
|