migrations/Version20200325105817.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 Version20200325105817 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->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql''Migration can only be executed safely on \'postgresql\'.');
  19.         $this->addSql('CREATE TABLE user_settings (id INT NOT NULL, user_id INT NOT NULL, standard_recipe_id INT DEFAULT NULL, language TEXT DEFAULT \'en\' NOT NULL, created_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, updated_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
  20.         $this->addSql('CREATE UNIQUE INDEX UNIQ_5C844C5A76ED395 ON user_settings (user_id)');
  21.         $this->addSql('CREATE UNIQUE INDEX UNIQ_5C844C5F28BBC1C ON user_settings (standard_recipe_id)');
  22.         $this->addSql('COMMENT ON COLUMN user_settings.language IS \'Application language.\'');
  23.         $this->addSql('COMMENT ON COLUMN user_settings.created_at IS \'Date of the entity creation. Should be fixed.\'');
  24.         $this->addSql('COMMENT ON COLUMN user_settings.updated_at IS \'Date of the last change in entity. Shouldn’t be set to other dates.\'');
  25.         $this->addSql('ALTER TABLE user_settings ADD CONSTRAINT FK_5C844C5A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  26.         $this->addSql('ALTER TABLE user_settings ADD CONSTRAINT FK_5C844C5F28BBC1C FOREIGN KEY (standard_recipe_id) REFERENCES recipes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  27.     }
  28.     public function down(Schema $schema) : void
  29.     {
  30.         // this down() migration is auto-generated, please modify it to your needs
  31.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql''Migration can only be executed safely on \'postgresql\'.');
  32.         $this->addSql('CREATE SCHEMA public');
  33.         $this->addSql('DROP TABLE user_settings');
  34.     }
  35. }