chill-bundles/src/Bundle/ChillMainBundle/migrations/Version20231108115104.php

40 lines
1.7 KiB
PHP

<?php
declare(strict_types=1);
namespace Chill\Migrations\Main;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Create dashboard item entity and link to news item
*/
final class Version20231108115104 extends AbstractMigration
{
public function getDescription(): string
{
return 'Create dashboard item entity and link to news item';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE SEQUENCE chill_main_dashboard_item_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE chill_main_dashboard_item (id INT NOT NULL, type VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('ALTER TABLE chill_main_news ADD dashboardItem_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE chill_main_news DROP type');
$this->addSql('ALTER TABLE chill_main_news ADD CONSTRAINT FK_96922AFBCBDA857A FOREIGN KEY (dashboardItem_id) REFERENCES chill_main_dashboard_item (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE UNIQUE INDEX UNIQ_96922AFBCBDA857A ON chill_main_news (dashboardItem_id)');
$this->addSql('ALTER TABLE chill_main_notification ALTER addressesemails DROP DEFAULT');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_main_news DROP CONSTRAINT FK_96922AFBCBDA857A');
$this->addSql('DROP SEQUENCE chill_main_dashboard_item_id_seq CASCADE');
$this->addSql('DROP TABLE chill_main_dashboard_item');
$this->addSql('ALTER TABLE chill_main_news ADD type VARCHAR(255) NOT NULL');
$this->addSql('ALTER TABLE chill_main_news DROP dashboardItem_id');
}
}