symfony-playground/migrations/Version20220522153147.php

65 lines
4.5 KiB
PHP
Raw Permalink Normal View History

2022-05-22 16:01:54 +00:00
<?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 Version20220522153147 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->addSql('CREATE TABLE employee3 (id INTEGER NOT NULL, job VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE person3 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush3_id INTEGER DEFAULT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, discr VARCHAR(255) NOT NULL)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_D4808643A02C14B3 ON person3 (toothbrush3_id)');
$this->addSql('CREATE TABLE toothbrush3 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, brand VARCHAR(255) NOT NULL)');
$this->addSql('DROP INDEX UNIQ_2250E3BCA25DC38');
$this->addSql('CREATE TEMPORARY TABLE __temp__employee1 AS SELECT id, toothbrush1_id, job, age, name FROM employee1');
$this->addSql('DROP TABLE employee1');
$this->addSql('CREATE TABLE employee1 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush1_id INTEGER DEFAULT NULL, job VARCHAR(255) NOT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, CONSTRAINT FK_2250E3BCA25DC38 FOREIGN KEY (toothbrush1_id) REFERENCES toothbrush1 (id) NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('INSERT INTO employee1 (id, toothbrush1_id, job, age, name) SELECT id, toothbrush1_id, job, age, name FROM __temp__employee1');
$this->addSql('DROP TABLE __temp__employee1');
$this->addSql('CREATE UNIQUE INDEX UNIQ_2250E3BCA25DC38 ON employee1 (toothbrush1_id)');
$this->addSql('DROP INDEX IDX_A387B6D5189073D6');
$this->addSql('CREATE TEMPORARY TABLE __temp__person2 AS SELECT id, toothbrush2_id, age, name, discr, job FROM person2');
$this->addSql('DROP TABLE person2');
$this->addSql('CREATE TABLE person2 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush2_id INTEGER DEFAULT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, discr VARCHAR(255) NOT NULL, job VARCHAR(255) DEFAULT NULL, CONSTRAINT FK_A387B6D5189073D6 FOREIGN KEY (toothbrush2_id) REFERENCES toothbrush2 (id) NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('INSERT INTO person2 (id, toothbrush2_id, age, name, discr, job) SELECT id, toothbrush2_id, age, name, discr, job FROM __temp__person2');
$this->addSql('DROP TABLE __temp__person2');
$this->addSql('CREATE INDEX IDX_A387B6D5189073D6 ON person2 (toothbrush2_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE employee3');
$this->addSql('DROP TABLE person3');
$this->addSql('DROP TABLE toothbrush3');
$this->addSql('DROP INDEX UNIQ_2250E3BCA25DC38');
$this->addSql('CREATE TEMPORARY TABLE __temp__employee1 AS SELECT id, toothbrush1_id, job, age, name FROM employee1');
$this->addSql('DROP TABLE employee1');
$this->addSql('CREATE TABLE employee1 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush1_id INTEGER DEFAULT NULL, job VARCHAR(255) NOT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL)');
$this->addSql('INSERT INTO employee1 (id, toothbrush1_id, job, age, name) SELECT id, toothbrush1_id, job, age, name FROM __temp__employee1');
$this->addSql('DROP TABLE __temp__employee1');
$this->addSql('CREATE UNIQUE INDEX UNIQ_2250E3BCA25DC38 ON employee1 (toothbrush1_id)');
$this->addSql('DROP INDEX IDX_A387B6D5189073D6');
$this->addSql('CREATE TEMPORARY TABLE __temp__person2 AS SELECT id, toothbrush2_id, age, name, discr, job FROM person2');
$this->addSql('DROP TABLE person2');
$this->addSql('CREATE TABLE person2 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush2_id INTEGER DEFAULT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, discr VARCHAR(255) NOT NULL, job VARCHAR(255) DEFAULT NULL)');
$this->addSql('INSERT INTO person2 (id, toothbrush2_id, age, name, discr, job) SELECT id, toothbrush2_id, age, name, discr, job FROM __temp__person2');
$this->addSql('DROP TABLE __temp__person2');
$this->addSql('CREATE INDEX IDX_A387B6D5189073D6 ON person2 (toothbrush2_id)');
}
}