m231118_081037_docs.php 1021 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. use yii\db\Schema;
  3. use yii\db\Migration;
  4. class m231118_081037_docs 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. '{{%docs}}',
  16. [
  17. 'id'=> $this->primaryKey()->unsigned(),
  18. 'title'=> $this->text()->notNull()->comment('Заголовок'),
  19. 'text'=> $this->text()->notNull()->comment('Описание'),
  20. 'cat'=> $this->string(128)->null()->defaultValue(null),
  21. 'uid'=> $this->string(128)->notNull(),
  22. ],$tableOptions
  23. );
  24. $this->createIndex('uid','{{%docs}}',['uid'],false);
  25. $this->createIndex('cat','{{%docs}}',['cat'],false);
  26. }
  27. public function safeDown()
  28. {
  29. $this->dropIndex('uid', '{{%docs}}');
  30. $this->dropIndex('cat', '{{%docs}}');
  31. $this->dropTable('{{%docs}}');
  32. }
  33. }