m231103_074827_report_photo.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. use yii\db\Schema;
  3. use yii\db\Migration;
  4. class m231103_074827_report_photo 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_photo}}',
  16. [
  17. 'id'=> $this->primaryKey()->unsigned(),
  18. 'topic_id'=> $this->integer()->unsigned()->notNull()->defaultValue(0),
  19. 'title'=> $this->text()->null()->defaultValue(null),
  20. 'sort'=> $this->integer()->unsigned()->notNull()->defaultValue(0),
  21. 'active'=> $this->integer()->notNull()->defaultValue(0),
  22. ],$tableOptions
  23. );
  24. $this->createIndex('sel','{{%report_photo}}',['id','topic_id','active'],false);
  25. $this->createIndex('sort','{{%report_photo}}',['sort'],false);
  26. }
  27. public function safeDown()
  28. {
  29. $this->dropIndex('sel', '{{%report_photo}}');
  30. $this->dropIndex('sort', '{{%report_photo}}');
  31. $this->dropTable('{{%report_photo}}');
  32. }
  33. }