<?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 Version20221221134415 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 TABLE connection_city (connection_id INT NOT NULL, city_id INT NOT NULL, INDEX IDX_EB4B050EDD03F01 (connection_id), INDEX IDX_EB4B050E8BAC62AF (city_id), PRIMARY KEY(connection_id, city_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE connection_city ADD CONSTRAINT FK_EB4B050EDD03F01 FOREIGN KEY (connection_id) REFERENCES connection (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE connection_city ADD CONSTRAINT FK_EB4B050E8BAC62AF FOREIGN KEY (city_id) REFERENCES city (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE connection ADD price DOUBLE PRECISION DEFAULT NULL, ADD from_date DATETIME DEFAULT NULL, ADD to_date DATETIME DEFAULT NULL, ADD price_from DOUBLE PRECISION DEFAULT NULL, ADD price_to DOUBLE PRECISION DEFAULT NULL');
$this->addSql('ALTER TABLE trip ADD hotel_city_id INT DEFAULT NULL, ADD from_date DATETIME DEFAULT NULL, ADD to_date DATETIME DEFAULT NULL, ADD number_of_people INT DEFAULT NULL, ADD price_from DOUBLE PRECISION DEFAULT NULL, DROP price, DROP hotel_city');
$this->addSql('ALTER TABLE trip ADD CONSTRAINT FK_7656F53B58E67C86 FOREIGN KEY (hotel_city_id) REFERENCES city (id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_7656F53B58E67C86 ON trip (hotel_city_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE connection_city DROP FOREIGN KEY FK_EB4B050EDD03F01');
$this->addSql('ALTER TABLE connection_city DROP FOREIGN KEY FK_EB4B050E8BAC62AF');
$this->addSql('DROP TABLE connection_city');
$this->addSql('ALTER TABLE connection DROP price, DROP from_date, DROP to_date, DROP price_from, DROP price_to');
$this->addSql('ALTER TABLE trip DROP FOREIGN KEY FK_7656F53B58E67C86');
$this->addSql('DROP INDEX UNIQ_7656F53B58E67C86 ON trip');
$this->addSql('ALTER TABLE trip ADD price INT NOT NULL, ADD hotel_city VARCHAR(255) NOT NULL, DROP hotel_city_id, DROP from_date, DROP to_date, DROP number_of_people, DROP price_from');
}
}