<?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 Version20241115145340 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 save_pdf (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', context_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', created_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', updated_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', name VARCHAR(255) NOT NULL, content LONGTEXT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_844A05C06B00C1CF (context_id), INDEX IDX_844A05C0B03A8386 (created_by_id), INDEX IDX_844A05C0896DBBDE (updated_by_id), 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 save_pdf ADD CONSTRAINT FK_844A05C06B00C1CF FOREIGN KEY (context_id) REFERENCES context (id)');
$this->addSql('ALTER TABLE save_pdf ADD CONSTRAINT FK_844A05C0B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE save_pdf ADD CONSTRAINT FK_844A05C0896DBBDE FOREIGN KEY (updated_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)');
$this->addSql('ALTER TABLE context ADD is_franchise TINYINT(1) DEFAULT 0 NOT NULL, ADD position INT NOT NULL');
$this->addSql('CREATE INDEX position ON context (position)');
$this->addSql('CREATE FULLTEXT INDEX render ON notification (render)');
$this->addSql('CREATE INDEX viewed ON notification (viewed)');
$this->addSql('CREATE INDEX readed ON notification (readed)');
$this->addSql('CREATE INDEX deleted ON notification (deleted)');
$this->addSql('CREATE INDEX created_at ON notification (created_at)');
$this->addSql('CREATE INDEX updated_at ON notification (updated_at)');
$this->addSql('ALTER TABLE user ADD is_solo TINYINT(1) DEFAULT 0 NOT NULL');
$this->addSql('ALTER TABLE webservice_key ADD context_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\'');
$this->addSql('ALTER TABLE webservice_key ADD CONSTRAINT FK_4AEB92AA6B00C1CF FOREIGN KEY (context_id) REFERENCES context (id)');
$this->addSql('CREATE INDEX IDX_4AEB92AA6B00C1CF ON webservice_key (context_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 save_pdf DROP FOREIGN KEY FK_844A05C06B00C1CF');
$this->addSql('ALTER TABLE save_pdf DROP FOREIGN KEY FK_844A05C0B03A8386');
$this->addSql('ALTER TABLE save_pdf DROP FOREIGN KEY FK_844A05C0896DBBDE');
$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 save_pdf');
$this->addSql('DROP TABLE users_establishments');
$this->addSql('ALTER TABLE user DROP is_solo');
$this->addSql('DROP INDEX position ON context');
$this->addSql('ALTER TABLE context DROP is_franchise, DROP position');
$this->addSql('ALTER TABLE webservice_key DROP FOREIGN KEY FK_4AEB92AA6B00C1CF');
$this->addSql('DROP INDEX IDX_4AEB92AA6B00C1CF ON webservice_key');
$this->addSql('ALTER TABLE webservice_key DROP context_id');
$this->addSql('DROP INDEX render ON notification');
$this->addSql('DROP INDEX viewed ON notification');
$this->addSql('DROP INDEX readed ON notification');
$this->addSql('DROP INDEX deleted ON notification');
$this->addSql('DROP INDEX created_at ON notification');
$this->addSql('DROP INDEX updated_at ON notification');
}
}