migrations/Version20230512131012.php line 1

  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20230512131012 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->addSql('CREATE SEQUENCE site_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  19.         $this->addSql('CREATE TABLE site (id INT NOT NULL, logo_id INT DEFAULT NULL, thumbnail_id INT DEFAULT NULL, copyright VARCHAR(64) DEFAULT NULL, title VARCHAR(64) DEFAULT NULL, subtitle VARCHAR(64) DEFAULT NULL, intro VARCHAR(512) DEFAULT NULL, domain VARCHAR(64) DEFAULT NULL, pages TEXT DEFAULT NULL, types TEXT DEFAULT NULL, created_date_time TIMESTAMP(6) WITHOUT TIME ZONE DEFAULT NULL, modified_date_time TIMESTAMP(6) WITHOUT TIME ZONE DEFAULT NULL, locked BOOLEAN DEFAULT NULL, PRIMARY KEY(id))');
  20.         $this->addSql('CREATE UNIQUE INDEX UNIQ_694309E4F98F144A ON site (logo_id)');
  21.         $this->addSql('CREATE UNIQUE INDEX UNIQ_694309E4FDFF2E92 ON site (thumbnail_id)');
  22.         $this->addSql('COMMENT ON COLUMN site.pages IS \'(DC2Type:array)\'');
  23.         $this->addSql('COMMENT ON COLUMN site.types IS \'(DC2Type:array)\'');
  24.         $this->addSql('ALTER TABLE site ADD CONSTRAINT FK_694309E4F98F144A FOREIGN KEY (logo_id) REFERENCES resource (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  25.         $this->addSql('ALTER TABLE site ADD CONSTRAINT FK_694309E4FDFF2E92 FOREIGN KEY (thumbnail_id) REFERENCES resource (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  26.         $this->addSql('ALTER TABLE "user" ADD site_id INT DEFAULT NULL');
  27.         $this->addSql('ALTER TABLE "user" ADD CONSTRAINT FK_8D93D649F6BD1646 FOREIGN KEY (site_id) REFERENCES site (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  28.         $this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D649F6BD1646 ON "user" (site_id)');
  29.     }
  30.     public function down(Schema $schema): void
  31.     {
  32.         // this down() migration is auto-generated, please modify it to your needs
  33.         $this->addSql('CREATE SCHEMA public');
  34.         $this->addSql('ALTER TABLE "user" DROP CONSTRAINT FK_8D93D649F6BD1646');
  35.         $this->addSql('DROP SEQUENCE site_id_seq CASCADE');
  36.         $this->addSql('ALTER TABLE site DROP CONSTRAINT FK_694309E4F98F144A');
  37.         $this->addSql('ALTER TABLE site DROP CONSTRAINT FK_694309E4FDFF2E92');
  38.         $this->addSql('DROP TABLE site');
  39.         $this->addSql('DROP INDEX UNIQ_8D93D649F6BD1646');
  40.         $this->addSql('ALTER TABLE "user" DROP site_id');
  41.     }
  42. }