m230918_092658_inquirer_answer.php 1015 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. use yii\db\Schema;
  3. use yii\db\Migration;
  4. class m230918_092658_inquirer_answer 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. '{{%inquirer_answer}}',
  16. [
  17. 'id'=> $this->primaryKey()->unsigned(),
  18. 'idq'=> $this->integer()->unsigned()->notNull()->comment('id вопроса'),
  19. 'text'=> $this->text()->notNull(),
  20. 'type'=> $this->string(64)->notNull()->defaultValue('simple'),
  21. 'count'=> $this->integer()->unsigned()->notNull()->defaultValue(0)->comment('счётчик'),
  22. ],$tableOptions
  23. );
  24. $this->createIndex('idq','{{%inquirer_answer}}',['idq'],false);
  25. }
  26. public function safeDown()
  27. {
  28. $this->dropIndex('idq', '{{%inquirer_answer}}');
  29. $this->dropTable('{{%inquirer_answer}}');
  30. }
  31. }