FestinHegre/migrations/Version20241017141339.php

47 lines
2.6 KiB
PHP

<?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 Version20241017141339 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 utilisateurs_tables (utilisateurs_id INT NOT NULL, tables_id INT NOT NULL, PRIMARY KEY(utilisateurs_id, tables_id))');
$this->addSql('CREATE INDEX IDX_A9A665291E969C5 ON utilisateurs_tables (utilisateurs_id)');
$this->addSql('CREATE INDEX IDX_A9A6652985405FD2 ON utilisateurs_tables (tables_id)');
$this->addSql('ALTER TABLE utilisateurs_tables ADD CONSTRAINT FK_A9A665291E969C5 FOREIGN KEY (utilisateurs_id) REFERENCES utilisateurs (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE utilisateurs_tables ADD CONSTRAINT FK_A9A6652985405FD2 FOREIGN KEY (tables_id) REFERENCES tables (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE tables_tables DROP CONSTRAINT fk_d19ed3b4a53aee6');
$this->addSql('ALTER TABLE tables_tables DROP CONSTRAINT fk_d19ed3b413b6fe69');
$this->addSql('DROP TABLE tables_tables');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('CREATE TABLE tables_tables (tables_source INT NOT NULL, tables_target INT NOT NULL, PRIMARY KEY(tables_source, tables_target))');
$this->addSql('CREATE INDEX idx_d19ed3b413b6fe69 ON tables_tables (tables_target)');
$this->addSql('CREATE INDEX idx_d19ed3b4a53aee6 ON tables_tables (tables_source)');
$this->addSql('ALTER TABLE tables_tables ADD CONSTRAINT fk_d19ed3b4a53aee6 FOREIGN KEY (tables_source) REFERENCES tables (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE tables_tables ADD CONSTRAINT fk_d19ed3b413b6fe69 FOREIGN KEY (tables_target) REFERENCES tables (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE utilisateurs_tables DROP CONSTRAINT FK_A9A665291E969C5');
$this->addSql('ALTER TABLE utilisateurs_tables DROP CONSTRAINT FK_A9A6652985405FD2');
$this->addSql('DROP TABLE utilisateurs_tables');
}
}