migrations/Version20211216063509.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 Version20211216063509 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 TABLE basket (id SERIAL 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))');
  19.         $this->addSql('COMMENT ON COLUMN basket.created_at IS \'(DC2Type:datetime_immutable)\'');
  20.         $this->addSql('COMMENT ON COLUMN basket.updated_at IS \'(DC2Type:datetime_immutable)\'');
  21.         $this->addSql('COMMENT ON COLUMN basket.deleted_at IS \'(DC2Type:datetime_immutable)\'');
  22.         $this->addSql('CREATE TABLE catalog (id SERIAL NOT NULL, title VARCHAR(255) NOT NULL, sort INT NOT NULL, created_at TIMESTAMP(0) WITH 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))');
  23.         $this->addSql('COMMENT ON COLUMN catalog.updated_at IS \'(DC2Type:datetime_immutable)\'');
  24.         $this->addSql('COMMENT ON COLUMN catalog.deleted_at IS \'(DC2Type:datetime_immutable)\'');
  25.         $this->addSql('CREATE TABLE category (id SERIAL NOT NULL, title VARCHAR(255) NOT NULL, sort INT NOT NULL, PRIMARY KEY(id))');
  26.         $this->addSql('CREATE TABLE category_catalog (category_id INT NOT NULL, catalog_id INT NOT NULL, PRIMARY KEY(category_id, catalog_id))');
  27.         $this->addSql('CREATE INDEX IDX_DCF4723912469DE2 ON category_catalog (category_id)');
  28.         $this->addSql('CREATE INDEX IDX_DCF47239CC3C66FC ON category_catalog (catalog_id)');
  29.         $this->addSql('CREATE TABLE product (id SERIAL NOT NULL, title VARCHAR(255) NOT NULL, favourite BOOLEAN NOT NULL, PRIMARY KEY(id))');
  30.         $this->addSql('CREATE TABLE product_category (product_id INT NOT NULL, category_id INT NOT NULL, PRIMARY KEY(product_id, category_id))');
  31.         $this->addSql('CREATE INDEX IDX_CDFC73564584665A ON product_category (product_id)');
  32.         $this->addSql('CREATE INDEX IDX_CDFC735612469DE2 ON product_category (category_id)');
  33.         $this->addSql('ALTER TABLE category_catalog ADD CONSTRAINT FK_DCF4723912469DE2 FOREIGN KEY (category_id) REFERENCES category (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
  34.         $this->addSql('ALTER TABLE category_catalog ADD CONSTRAINT FK_DCF47239CC3C66FC FOREIGN KEY (catalog_id) REFERENCES catalog (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
  35.         $this->addSql('ALTER TABLE product_category ADD CONSTRAINT FK_CDFC73564584665A FOREIGN KEY (product_id) REFERENCES product (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
  36.         $this->addSql('ALTER TABLE product_category ADD CONSTRAINT FK_CDFC735612469DE2 FOREIGN KEY (category_id) REFERENCES category (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
  37.     }
  38.     public function down(Schema $schema): void
  39.     {
  40.         // this down() migration is auto-generated, please modify it to your needs
  41.         $this->addSql('CREATE SCHEMA public');
  42.         $this->addSql('ALTER TABLE category_catalog DROP CONSTRAINT FK_DCF47239CC3C66FC');
  43.         $this->addSql('ALTER TABLE category_catalog DROP CONSTRAINT FK_DCF4723912469DE2');
  44.         $this->addSql('ALTER TABLE product_category DROP CONSTRAINT FK_CDFC735612469DE2');
  45.         $this->addSql('ALTER TABLE product_category DROP CONSTRAINT FK_CDFC73564584665A');
  46.         $this->addSql('DROP TABLE basket');
  47.         $this->addSql('DROP TABLE catalog');
  48.         $this->addSql('DROP TABLE category');
  49.         $this->addSql('DROP TABLE category_catalog');
  50.         $this->addSql('DROP TABLE product');
  51.         $this->addSql('DROP TABLE product_category');
  52.     }
  53. }