12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- use yii\db\Schema;
- use yii\db\Migration;
- class m231103_074755_report_topic extends Migration
- {
- public function init()
- {
- $this->db = 'db';
- parent::init();
- }
- public function safeUp()
- {
- $tableOptions = 'ENGINE=InnoDB';
- $this->createTable(
- '{{%report_topic}}',
- [
- 'id'=> $this->primaryKey()->unsigned(),
- 'parent_id'=> $this->integer()->unsigned()->null()->defaultValue(0),
- 'date'=> $this->datetime()->notNull()->defaultExpression("CURRENT_TIMESTAMP"),
- 'title'=> $this->text()->null()->defaultValue(null),
- 'body'=> $this->text()->notNull(),
- 'folder'=> $this->string(250)->notNull()->defaultValue(''),
- 'sort'=> $this->integer()->notNull()->defaultValue(0),
- 'active'=> $this->integer()->notNull()->defaultValue(0),
- ],$tableOptions
- );
- $this->createIndex('sel','{{%report_topic}}',['id','parent_id','active'],false);
- $this->createIndex('sort','{{%report_topic}}',['sort'],false);
- }
- public function safeDown()
- {
- $this->dropIndex('sel', '{{%report_topic}}');
- $this->dropIndex('sort', '{{%report_topic}}');
- $this->dropTable('{{%report_topic}}');
- }
- }
|