<?php

use yii\db\Schema;
use yii\db\Migration;

class m231004_025236_inquirer_log extends Migration
{

    public function init()
    {
        $this->db = 'db';
        parent::init();
    }

    public function safeUp()
    {
        $tableOptions = 'ENGINE=InnoDB';

        $this->createTable(
            '{{%inquirer_log}}',
            [
                'id'=> $this->primaryKey()->unsigned(),
                'idq'=> $this->integer()->unsigned()->notNull(),
                'ida'=> $this->integer()->unsigned()->notNull(),
                'hash'=> $this->string(64)->notNull(),
                'dt'=> $this->timestamp()->notNull()->defaultExpression("CURRENT_TIMESTAMP"),
            ],$tableOptions
        );
        $this->createIndex('dt','{{%inquirer_log}}',['dt'],false);
        $this->createIndex('test','{{%inquirer_log}}',['ida','hash','idq'],false);
        $this->createIndex('test2','{{%inquirer_log}}',['idq','hash'],false);

    }

    public function safeDown()
    {
        $this->dropIndex('dt', '{{%inquirer_log}}');
        $this->dropIndex('test', '{{%inquirer_log}}');
        $this->dropIndex('test2', '{{%inquirer_log}}');
        $this->dropTable('{{%inquirer_log}}');
    }
}
