<?php

declare(strict_types=1);

namespace DoctrineMigrations;

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

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20201125223032 extends AbstractMigration
{
    public function getDescription() : string
    {
        return '';
    }

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

        $this->addSql('CREATE TABLE rodic (id INT AUTO_INCREMENT NOT NULL, jmeno VARCHAR(255) NOT NULL, prijmeni VARCHAR(255) NOT NULL, titul VARCHAR(50) DEFAULT NULL, ulice VARCHAR(255) NOT NULL, obec VARCHAR(255) NOT NULL, m_cast VARCHAR(255) NOT NULL, stat VARCHAR(255) NOT NULL, cis_pop VARCHAR(255) NOT NULL, psc INT NOT NULL, telefon VARCHAR(13) DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE rodic_zak (rodic_id INT NOT NULL, zak_id INT NOT NULL, INDEX IDX_D3896657417D6937 (rodic_id), INDEX IDX_D3896657CA0EBDD9 (zak_id), PRIMARY KEY(rodic_id, zak_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('ALTER TABLE rodic_zak ADD CONSTRAINT FK_D3896657417D6937 FOREIGN KEY (rodic_id) REFERENCES rodic (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE rodic_zak ADD CONSTRAINT FK_D3896657CA0EBDD9 FOREIGN KEY (zak_id) REFERENCES zak (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE user ADD rodic_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE user ADD CONSTRAINT FK_8D93D649417D6937 FOREIGN KEY (rodic_id) REFERENCES rodic (id)');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D649417D6937 ON user (rodic_id)');
    }

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

        $this->addSql('ALTER TABLE user DROP FOREIGN KEY FK_8D93D649417D6937');
        $this->addSql('ALTER TABLE rodic_zak DROP FOREIGN KEY FK_D3896657417D6937');
        $this->addSql('DROP TABLE rodic');
        $this->addSql('DROP TABLE rodic_zak');
        $this->addSql('DROP INDEX UNIQ_8D93D649417D6937 ON user');
        $this->addSql('ALTER TABLE user DROP rodic_id');
    }
}
