migrations/Version20221202121419.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 Version20221202121419 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 contact (id SERIAL NOT NULL, phone VARCHAR(255) DEFAULT NULL, email VARCHAR(255) DEFAULT NULL, site_url VARCHAR(255) DEFAULT NULL, ok_url VARCHAR(255) DEFAULT NULL, vk_url VARCHAR(255) DEFAULT NULL, tg_url VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))');
  19.         $this->addSql('COMMENT ON TABLE contact IS \'Контакты для спорт.объектов и организаций\'');
  20.         $this->addSql('COMMENT ON COLUMN contact.phone IS \'Телефон\'');
  21.         $this->addSql('COMMENT ON COLUMN contact.email IS \'Email\'');
  22.         $this->addSql('COMMENT ON COLUMN contact.site_url IS \'Ссылка на произвольный сайт\'');
  23.         $this->addSql('COMMENT ON COLUMN contact.ok_url IS \'Ссылка на Одноклассники\'');
  24.         $this->addSql('COMMENT ON COLUMN contact.vk_url IS \'Ссылка на Вконтакте\'');
  25.         $this->addSql('COMMENT ON COLUMN contact.tg_url IS \'Ссылка на Телеграм\'');
  26.         $this->addSql('ALTER TABLE organization ADD contact_id INT DEFAULT NULL');
  27.         $this->addSql('ALTER TABLE organization ADD CONSTRAINT FK_C1EE637CE7A1254A FOREIGN KEY (contact_id) REFERENCES contact (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  28.         $this->addSql('CREATE INDEX IDX_C1EE637CE7A1254A ON organization (contact_id)');
  29.         $this->addSql('ALTER TABLE sport_object ADD contact_id INT DEFAULT NULL');
  30.         $this->addSql('ALTER TABLE sport_object ADD CONSTRAINT FK_CC727F4DE7A1254A FOREIGN KEY (contact_id) REFERENCES contact (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  31.         $this->addSql('CREATE INDEX IDX_CC727F4DE7A1254A ON sport_object (contact_id)');
  32.     }
  33.     public function down(Schema $schema): void
  34.     {
  35.         // this down() migration is auto-generated, please modify it to your needs
  36.         $this->addSql('ALTER TABLE organization DROP CONSTRAINT FK_C1EE637CE7A1254A');
  37.         $this->addSql('ALTER TABLE sport_object DROP CONSTRAINT FK_CC727F4DE7A1254A');
  38.         $this->addSql('DROP TABLE contact');
  39.         $this->addSql('DROP INDEX IDX_CC727F4DE7A1254A');
  40.         $this->addSql('ALTER TABLE sport_object DROP contact_id');
  41.         $this->addSql('DROP INDEX IDX_C1EE637CE7A1254A');
  42.         $this->addSql('ALTER TABLE organization DROP contact_id');
  43.     }
  44. }