<?php
declare(strict_types=1);
namespace CoreMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240520161118 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 establishment (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', country_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', context_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', created_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', updated_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', deleted_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', name VARCHAR(128) NOT NULL, reference VARCHAR(128) DEFAULT NULL, address VARCHAR(128) DEFAULT NULL, address2 VARCHAR(128) DEFAULT NULL, postcode VARCHAR(32) DEFAULT NULL, city VARCHAR(128) DEFAULT NULL, phone VARCHAR(32) DEFAULT NULL, email VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, INDEX IDX_DBEFB1EEF92F3E70 (country_id), INDEX IDX_DBEFB1EE6B00C1CF (context_id), INDEX IDX_DBEFB1EEB03A8386 (created_by_id), INDEX IDX_DBEFB1EE896DBBDE (updated_by_id), INDEX IDX_DBEFB1EEC76F1F52 (deleted_by_id), INDEX name (name), INDEX reference (reference), INDEX postcode (postcode), INDEX email (email), INDEX deleted_at (deleted_at), INDEX created_at (created_at), INDEX updated_at (updated_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE users_establishments (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', user_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', establishment_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', INDEX IDX_22DF7670A76ED395 (user_id), INDEX IDX_22DF76708565851 (establishment_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE establishment ADD CONSTRAINT FK_DBEFB1EEF92F3E70 FOREIGN KEY (country_id) REFERENCES country (id)');
$this->addSql('ALTER TABLE establishment ADD CONSTRAINT FK_DBEFB1EE6B00C1CF FOREIGN KEY (context_id) REFERENCES context (id)');
$this->addSql('ALTER TABLE establishment ADD CONSTRAINT FK_DBEFB1EEB03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE establishment ADD CONSTRAINT FK_DBEFB1EE896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE establishment ADD CONSTRAINT FK_DBEFB1EEC76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE users_establishments ADD CONSTRAINT FK_22DF7670A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE users_establishments ADD CONSTRAINT FK_22DF76708565851 FOREIGN KEY (establishment_id) REFERENCES establishment (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE establishment DROP FOREIGN KEY FK_DBEFB1EEF92F3E70');
$this->addSql('ALTER TABLE establishment DROP FOREIGN KEY FK_DBEFB1EE6B00C1CF');
$this->addSql('ALTER TABLE establishment DROP FOREIGN KEY FK_DBEFB1EEB03A8386');
$this->addSql('ALTER TABLE establishment DROP FOREIGN KEY FK_DBEFB1EE896DBBDE');
$this->addSql('ALTER TABLE establishment DROP FOREIGN KEY FK_DBEFB1EEC76F1F52');
$this->addSql('ALTER TABLE users_establishments DROP FOREIGN KEY FK_22DF7670A76ED395');
$this->addSql('ALTER TABLE users_establishments DROP FOREIGN KEY FK_22DF76708565851');
$this->addSql('DROP TABLE establishment');
$this->addSql('DROP TABLE users_establishments');
}
}