Files
SomniaRooms/migrations/Version20240909131104.php
T

43 lines
2.0 KiB
PHP

<?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 Version20240909131104 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->addSql('CREATE SEQUENCE bed_type_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE bed_type (id INT NOT NULL, name VARCHAR(255) DEFAULT NULL, icon_url VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE room_category_bed_type (room_category_id INT NOT NULL, bed_type_id INT NOT NULL, amount INT NOT NULL, PRIMARY KEY(room_category_id, bed_type_id))');
$this->addSql('CREATE INDEX IDX_FB45954567333DD ON room_category_bed_type (room_category_id)');
$this->addSql('CREATE INDEX IDX_FB4595458158330E ON room_category_bed_type (bed_type_id)');
$this->addSql('ALTER TABLE room_category_bed_type ADD CONSTRAINT FK_FB45954567333DD FOREIGN KEY (room_category_id) REFERENCES room_category (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE room_category_bed_type ADD CONSTRAINT FK_FB4595458158330E FOREIGN KEY (bed_type_id) REFERENCES bed_type (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('DROP SEQUENCE bed_type_id_seq CASCADE');
$this->addSql('ALTER TABLE room_category_bed_type DROP CONSTRAINT FK_FB45954567333DD');
$this->addSql('ALTER TABLE room_category_bed_type DROP CONSTRAINT FK_FB4595458158330E');
$this->addSql('DROP TABLE bed_type');
$this->addSql('DROP TABLE room_category_bed_type');
}
}