migrations/Version20221111093815.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 Version20221111093815 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 organization (id SERIAL NOT NULL, file_id INT DEFAULT NULL, created_by_id INT NOT NULL, name VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, address VARCHAR(255) DEFAULT NULL, organization_info TEXT DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, PRIMARY KEY(id))');
  19.         $this->addSql('CREATE INDEX IDX_C1EE637C93CB796C ON organization (file_id)');
  20.         $this->addSql('CREATE INDEX IDX_C1EE637CB03A8386 ON organization (created_by_id)');
  21.         $this->addSql('COMMENT ON TABLE organization IS \'Спортивные организации\'');
  22.         $this->addSql('COMMENT ON COLUMN organization.name IS \'Наименование\'');
  23.         $this->addSql('COMMENT ON COLUMN organization.description IS \'Описание\'');
  24.         $this->addSql('COMMENT ON COLUMN organization.address IS \'Адрес\'');
  25.         $this->addSql('COMMENT ON COLUMN organization.organization_info IS \'Информация о юр.лице\'');
  26.         $this->addSql('CREATE TABLE organization_image (organization_id INT NOT NULL, file_id INT NOT NULL, PRIMARY KEY(organization_id, file_id))');
  27.         $this->addSql('CREATE INDEX IDX_4BBAE29832C8A3DE ON organization_image (organization_id)');
  28.         $this->addSql('CREATE INDEX IDX_4BBAE29893CB796C ON organization_image (file_id)');
  29.         $this->addSql('CREATE TABLE organization_doc (organization_id INT NOT NULL, file_id INT NOT NULL, PRIMARY KEY(organization_id, file_id))');
  30.         $this->addSql('CREATE INDEX IDX_8CCCA28732C8A3DE ON organization_doc (organization_id)');
  31.         $this->addSql('CREATE INDEX IDX_8CCCA28793CB796C ON organization_doc (file_id)');
  32.         $this->addSql('CREATE TABLE organization_section (id SERIAL NOT NULL, organization_id INT DEFAULT NULL, sport_section_id INT DEFAULT NULL, sport_object_id INT DEFAULT NULL, url VARCHAR(500) DEFAULT NULL, PRIMARY KEY(id))');
  33.         $this->addSql('CREATE INDEX IDX_E0A1F2AC32C8A3DE ON organization_section (organization_id)');
  34.         $this->addSql('CREATE INDEX IDX_E0A1F2ACEB0B7C67 ON organization_section (sport_section_id)');
  35.         $this->addSql('CREATE INDEX IDX_E0A1F2AC8AFAE46 ON organization_section (sport_object_id)');
  36.         $this->addSql('CREATE UNIQUE INDEX organization_section_unique ON organization_section (organization_id, sport_section_id)');
  37.         $this->addSql('COMMENT ON TABLE organization_section IS \'Связь спортивных секций со спортивными организациями.\'');
  38.         $this->addSql('ALTER TABLE organization ADD CONSTRAINT FK_C1EE637C93CB796C FOREIGN KEY (file_id) REFERENCES file (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  39.         $this->addSql('ALTER TABLE organization ADD CONSTRAINT FK_C1EE637CB03A8386 FOREIGN KEY (created_by_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  40.         $this->addSql('ALTER TABLE organization_image ADD CONSTRAINT FK_4BBAE29832C8A3DE FOREIGN KEY (organization_id) REFERENCES organization (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
  41.         $this->addSql('ALTER TABLE organization_image ADD CONSTRAINT FK_4BBAE29893CB796C FOREIGN KEY (file_id) REFERENCES file (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
  42.         $this->addSql('ALTER TABLE organization_doc ADD CONSTRAINT FK_8CCCA28732C8A3DE FOREIGN KEY (organization_id) REFERENCES organization (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
  43.         $this->addSql('ALTER TABLE organization_doc ADD CONSTRAINT FK_8CCCA28793CB796C FOREIGN KEY (file_id) REFERENCES file (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
  44.         $this->addSql('ALTER TABLE organization_section ADD CONSTRAINT FK_E0A1F2AC32C8A3DE FOREIGN KEY (organization_id) REFERENCES organization (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  45.         $this->addSql('ALTER TABLE organization_section ADD CONSTRAINT FK_E0A1F2ACEB0B7C67 FOREIGN KEY (sport_section_id) REFERENCES sport_section (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  46.         $this->addSql('ALTER TABLE organization_section ADD CONSTRAINT FK_E0A1F2AC8AFAE46 FOREIGN KEY (sport_object_id) REFERENCES sport_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  47.         $this->addSql('ALTER TABLE job ADD organization_id INT DEFAULT NULL');
  48.         $this->addSql('ALTER TABLE job ADD organization_section_id INT DEFAULT NULL');
  49.         $this->addSql('ALTER TABLE job ADD CONSTRAINT FK_FBD8E0F832C8A3DE FOREIGN KEY (organization_id) REFERENCES organization (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  50.         $this->addSql('ALTER TABLE job ADD CONSTRAINT FK_FBD8E0F831787195 FOREIGN KEY (organization_section_id) REFERENCES organization_section (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
  51.         $this->addSql('CREATE INDEX IDX_FBD8E0F832C8A3DE ON job (organization_id)');
  52.         $this->addSql('CREATE INDEX IDX_FBD8E0F831787195 ON job (organization_section_id)');
  53.     }
  54.     public function down(Schema $schema): void
  55.     {
  56.         // this down() migration is auto-generated, please modify it to your needs
  57.         $this->addSql('ALTER TABLE job DROP CONSTRAINT FK_FBD8E0F832C8A3DE');
  58.         $this->addSql('ALTER TABLE job DROP CONSTRAINT FK_FBD8E0F831787195');
  59.         $this->addSql('ALTER TABLE organization DROP CONSTRAINT FK_C1EE637C93CB796C');
  60.         $this->addSql('ALTER TABLE organization DROP CONSTRAINT FK_C1EE637CB03A8386');
  61.         $this->addSql('ALTER TABLE organization_image DROP CONSTRAINT FK_4BBAE29832C8A3DE');
  62.         $this->addSql('ALTER TABLE organization_image DROP CONSTRAINT FK_4BBAE29893CB796C');
  63.         $this->addSql('ALTER TABLE organization_doc DROP CONSTRAINT FK_8CCCA28732C8A3DE');
  64.         $this->addSql('ALTER TABLE organization_doc DROP CONSTRAINT FK_8CCCA28793CB796C');
  65.         $this->addSql('ALTER TABLE organization_section DROP CONSTRAINT FK_E0A1F2AC32C8A3DE');
  66.         $this->addSql('ALTER TABLE organization_section DROP CONSTRAINT FK_E0A1F2ACEB0B7C67');
  67.         $this->addSql('ALTER TABLE organization_section DROP CONSTRAINT FK_E0A1F2AC8AFAE46');
  68.         $this->addSql('DROP TABLE organization');
  69.         $this->addSql('DROP TABLE organization_image');
  70.         $this->addSql('DROP TABLE organization_doc');
  71.         $this->addSql('DROP TABLE organization_section');
  72.         $this->addSql('DROP INDEX IDX_FBD8E0F832C8A3DE');
  73.         $this->addSql('DROP INDEX IDX_FBD8E0F831787195');
  74.         $this->addSql('ALTER TABLE job DROP organization_id');
  75.         $this->addSql('ALTER TABLE job DROP organization_section_id');
  76.     }
  77. }