<?php declare(strict_types=1);

namespace Application\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Migrations\AbstractMigration;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20190404084923 extends AbstractMigration
{
    public function up(Schema $schema) : void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

        $this->addSql('CREATE SEQUENCE mer_ITDLC_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
        $this->addSql('CREATE TABLE mer_ITDLC (id INT NOT NULL, ope_id INT DEFAULT NULL, inge_id INT DEFAULT NULL, first_date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, first_date_start_time TIME(0) WITHOUT TIME ZONE DEFAULT NULL, first_date_end_time TIME(0) WITHOUT TIME ZONE DEFAULT NULL, second_date TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, second_date_start_time TIME(0) WITHOUT TIME ZONE DEFAULT NULL, second_date_end_time TIME(0) WITHOUT TIME ZONE DEFAULT NULL, third_date TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, third_date_start_time TIME(0) WITHOUT TIME ZONE DEFAULT NULL, third_date_end_time TIME(0) WITHOUT TIME ZONE DEFAULT NULL, answer BOOLEAN DEFAULT NULL, answer_date TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX IDX_7322747E244AE7F0 ON mer_ITDLC (ope_id)');
        $this->addSql('CREATE INDEX IDX_7322747EF56082C ON mer_ITDLC (inge_id)');
        $this->addSql('ALTER TABLE mer_ITDLC ADD CONSTRAINT FK_7322747E244AE7F0 FOREIGN KEY (ope_id) REFERENCES OperationITDLC (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE mer_ITDLC ADD CONSTRAINT FK_7322747EF56082C FOREIGN KEY (inge_id) REFERENCES fos_user (id) NOT DEFERRABLE INITIALLY IMMEDIATE');

    }

    public function down(Schema $schema) : void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

        $this->addSql('CREATE SCHEMA public');
        $this->addSql('DROP SEQUENCE mer_ITDLC_id_seq CASCADE');
        $this->addSql('DROP TABLE mer_ITDLC');
    }
}
