m231004_025236_inquirer_log.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. use yii\db\Schema;
  3. use yii\db\Migration;
  4. class m231004_025236_inquirer_log 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_log}}',
  16. [
  17. 'id'=> $this->primaryKey()->unsigned(),
  18. 'idq'=> $this->integer()->unsigned()->notNull(),
  19. 'ida'=> $this->integer()->unsigned()->notNull(),
  20. 'hash'=> $this->string(64)->notNull(),
  21. 'dt'=> $this->timestamp()->notNull()->defaultExpression("CURRENT_TIMESTAMP"),
  22. ],$tableOptions
  23. );
  24. $this->createIndex('dt','{{%inquirer_log}}',['dt'],false);
  25. $this->createIndex('test','{{%inquirer_log}}',['ida','hash','idq'],false);
  26. $this->createIndex('test2','{{%inquirer_log}}',['idq','hash'],false);
  27. }
  28. public function safeDown()
  29. {
  30. $this->dropIndex('dt', '{{%inquirer_log}}');
  31. $this->dropIndex('test', '{{%inquirer_log}}');
  32. $this->dropIndex('test2', '{{%inquirer_log}}');
  33. $this->dropTable('{{%inquirer_log}}');
  34. }
  35. }