migrations/Version20220124055653.php line 1

Open in your IDE?
  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 Version20220124055653 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 store_attrs_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  19.         $this->addSql('CREATE SEQUENCE store_work_hours_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  20.         $this->addSql('CREATE TABLE store_attrs (id INT NOT NULL, owner_id_id INT DEFAULT NULL, creater_id_id INT DEFAULT NULL, updater_id_id INT DEFAULT NULL, deleter_id_id INT DEFAULT NULL, title VARCHAR(255) NOT NULL, sort INT NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, deleted_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, active BOOLEAN NOT NULL, PRIMARY KEY(id))');
  21.         $this->addSql('CREATE INDEX IDX_7DEE334C8FDDAB70 ON store_attrs (owner_id_id)');
  22.         $this->addSql('CREATE INDEX IDX_7DEE334C61979421 ON store_attrs (creater_id_id)');
  23.         $this->addSql('CREATE INDEX IDX_7DEE334C58C0AC79 ON store_attrs (updater_id_id)');
  24.         $this->addSql('CREATE INDEX IDX_7DEE334C16C208F5 ON store_attrs (deleter_id_id)');
  25.         $this->addSql('COMMENT ON COLUMN store_attrs.created_at IS \'(DC2Type:datetime_immutable)\'');
  26.         $this->addSql('COMMENT ON COLUMN store_attrs.updated_at IS \'(DC2Type:datetime_immutable)\'');
  27.         $this->addSql('COMMENT ON COLUMN store_attrs.deleted_at IS \'(DC2Type:datetime_immutable)\'');
  28.         $this->addSql('CREATE TABLE store_work_hours (id INT NOT NULL, owner_id_id INT DEFAULT NULL, creater_id_id INT DEFAULT NULL, updater_id_id INT DEFAULT NULL, deleter_id_id INT DEFAULT NULL, title VARCHAR(255) NOT NULL, sort INT NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, deleted_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, active BOOLEAN DEFAULT NULL, PRIMARY KEY(id))');
  29.         $this->addSql('CREATE INDEX IDX_8C089D4F8FDDAB70 ON store_work_hours (owner_id_id)');
  30.         $this->addSql('CREATE INDEX IDX_8C089D4F61979421 ON store_work_hours (creater_id_id)');
  31.         $this->addSql('CREATE INDEX IDX_8C089D4F58C0AC79 ON store_work_hours (updater_id_id)');
  32.         $this->addSql('CREATE INDEX IDX_8C089D4F16C208F5 ON store_work_hours (deleter_id_id)');
  33.         $this->addSql('COMMENT ON COLUMN store_work_hours.created_at IS \'(DC2Type:datetime_immutable)\'');
  34.         $this->addSql('COMMENT ON COLUMN store_work_hours.updated_at IS \'(DC2Type:datetime_immutable)\'');
  35.         $this->addSql('COMMENT ON COLUMN store_work_hours.deleted_at IS \'(DC2Type:datetime_immutable)\'');
  36.         $this->addSql('CREATE TABLE stores_store_work_hours (stores_id INT NOT NULL, store_work_hours_id INT NOT NULL, PRIMARY KEY(stores_id, store_work_hours_id))');
  37.         $this->addSql('CREATE INDEX IDX_5616B818D710F7F ON stores_store_work_hours (stores_id)');
  38.         $this->addSql('CREATE INDEX IDX_5616B81D7B37324 ON stores_store_work_hours (store_work_hours_id)');
  39.         $this->addSql('ALTER TABLE store_attrs ADD CONSTRAINT FK_7DEE334C8FDDAB70 FOREIGN KEY (owner_id_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  40.         $this->addSql('ALTER TABLE store_attrs ADD CONSTRAINT FK_7DEE334C61979421 FOREIGN KEY (creater_id_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  41.         $this->addSql('ALTER TABLE store_attrs ADD CONSTRAINT FK_7DEE334C58C0AC79 FOREIGN KEY (updater_id_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  42.         $this->addSql('ALTER TABLE store_attrs ADD CONSTRAINT FK_7DEE334C16C208F5 FOREIGN KEY (deleter_id_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  43.         $this->addSql('ALTER TABLE store_work_hours ADD CONSTRAINT FK_8C089D4F8FDDAB70 FOREIGN KEY (owner_id_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  44.         $this->addSql('ALTER TABLE store_work_hours ADD CONSTRAINT FK_8C089D4F61979421 FOREIGN KEY (creater_id_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  45.         $this->addSql('ALTER TABLE store_work_hours ADD CONSTRAINT FK_8C089D4F58C0AC79 FOREIGN KEY (updater_id_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  46.         $this->addSql('ALTER TABLE store_work_hours ADD CONSTRAINT FK_8C089D4F16C208F5 FOREIGN KEY (deleter_id_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  47.         $this->addSql('ALTER TABLE stores_store_work_hours ADD CONSTRAINT FK_5616B818D710F7F FOREIGN KEY (stores_id) REFERENCES "stores" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
  48.         $this->addSql('ALTER TABLE stores_store_work_hours ADD CONSTRAINT FK_5616B81D7B37324 FOREIGN KEY (store_work_hours_id) REFERENCES store_work_hours (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
  49.     }
  50.     public function down(Schema $schema): void
  51.     {
  52.         // this down() migration is auto-generated, please modify it to your needs
  53.         $this->addSql('CREATE SCHEMA public');
  54.         $this->addSql('ALTER TABLE stores_store_work_hours DROP CONSTRAINT FK_5616B81D7B37324');
  55.         $this->addSql('DROP SEQUENCE store_attrs_id_seq CASCADE');
  56.         $this->addSql('DROP SEQUENCE store_work_hours_id_seq CASCADE');
  57.         $this->addSql('DROP TABLE store_attrs');
  58.         $this->addSql('DROP TABLE store_work_hours');
  59.         $this->addSql('DROP TABLE stores_store_work_hours');
  60.     }
  61. }