<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200325105817 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$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))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_5C844C5A76ED395 ON user_settings (user_id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_5C844C5F28BBC1C ON user_settings (standard_recipe_id)');
$this->addSql('COMMENT ON COLUMN user_settings.language IS \'Application language.\'');
$this->addSql('COMMENT ON COLUMN user_settings.created_at IS \'Date of the entity creation. Should be fixed.\'');
$this->addSql('COMMENT ON COLUMN user_settings.updated_at IS \'Date of the last change in entity. Shouldn’t be set to other dates.\'');
$this->addSql('ALTER TABLE user_settings ADD CONSTRAINT FK_5C844C5A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE user_settings ADD CONSTRAINT FK_5C844C5F28BBC1C FOREIGN KEY (standard_recipe_id) REFERENCES recipes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE SCHEMA public');
$this->addSql('DROP TABLE user_settings');
}
}