m231103_074755_report_topic.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. use yii\db\Schema;
  3. use yii\db\Migration;
  4. class m231103_074755_report_topic extends Migration
  5. {
  6. public function init()
  7. {
  8. $this->db = 'db';
  9. parent::init();
  10. }
  11. public function safeUp()
  12. {
  13. $tableOptions = 'ENGINE=InnoDB';
  14. $this->createTable(
  15. '{{%report_topic}}',
  16. [
  17. 'id'=> $this->primaryKey()->unsigned(),
  18. 'parent_id'=> $this->integer()->unsigned()->null()->defaultValue(0),
  19. 'date'=> $this->datetime()->notNull()->defaultExpression("CURRENT_TIMESTAMP"),
  20. 'title'=> $this->text()->null()->defaultValue(null),
  21. 'body'=> $this->text()->notNull(),
  22. 'folder'=> $this->string(250)->notNull()->defaultValue(''),
  23. 'sort'=> $this->integer()->notNull()->defaultValue(0),
  24. 'active'=> $this->integer()->notNull()->defaultValue(0),
  25. ],$tableOptions
  26. );
  27. $this->createIndex('sel','{{%report_topic}}',['id','parent_id','active'],false);
  28. $this->createIndex('sort','{{%report_topic}}',['sort'],false);
  29. }
  30. public function safeDown()
  31. {
  32. $this->dropIndex('sel', '{{%report_topic}}');
  33. $this->dropIndex('sort', '{{%report_topic}}');
  34. $this->dropTable('{{%report_topic}}');
  35. }
  36. }