<?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 Version20211013105910 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 answer (id INT AUTO_INCREMENT NOT NULL, question_id INT NOT NULL, content VARCHAR(255) NOT NULL, INDEX IDX_DADD4A251E27F6BF (question_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE campaign (id INT AUTO_INCREMENT NOT NULL, template_id INT NOT NULL, name VARCHAR(255) NOT NULL, target VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, sent INT NOT NULL, open INT NOT NULL, INDEX IDX_1F1512DD5DA0FB8 (template_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE email_template (id INT AUTO_INCREMENT NOT NULL, hotel_id INT NOT NULL, name VARCHAR(255) NOT NULL, content LONGTEXT NOT NULL, content_json LONGTEXT NOT NULL, type VARCHAR(255) NOT NULL, INDEX IDX_9C0600CA3243BB18 (hotel_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE proposal (id INT AUTO_INCREMENT NOT NULL, question_id INT NOT NULL, content VARCHAR(255) NOT NULL, INDEX IDX_BFE594721E27F6BF (question_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE question (id INT AUTO_INCREMENT NOT NULL, survey_id INT NOT NULL, content VARCHAR(255) NOT NULL, position INT NOT NULL, type JSON NOT NULL, INDEX IDX_B6F7494EB3FE509D (survey_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE survey (id INT AUTO_INCREMENT NOT NULL, hotel_id INT NOT NULL, name VARCHAR(255) NOT NULL, INDEX IDX_AD5F9BFC3243BB18 (hotel_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE answer ADD CONSTRAINT FK_DADD4A251E27F6BF FOREIGN KEY (question_id) REFERENCES question (id)');
$this->addSql('ALTER TABLE campaign ADD CONSTRAINT FK_1F1512DD5DA0FB8 FOREIGN KEY (template_id) REFERENCES email_template (id)');
$this->addSql('ALTER TABLE email_template ADD CONSTRAINT FK_9C0600CA3243BB18 FOREIGN KEY (hotel_id) REFERENCES hotel (id)');
$this->addSql('ALTER TABLE proposal ADD CONSTRAINT FK_BFE594721E27F6BF FOREIGN KEY (question_id) REFERENCES question (id)');
$this->addSql('ALTER TABLE question ADD CONSTRAINT FK_B6F7494EB3FE509D FOREIGN KEY (survey_id) REFERENCES survey (id)');
$this->addSql('ALTER TABLE survey ADD CONSTRAINT FK_AD5F9BFC3243BB18 FOREIGN KEY (hotel_id) REFERENCES hotel (id)');
//$this->addSql('ALTER TABLE client CHANGE uid uid VARCHAR(255) NOT NULL, CHANGE civility civility VARCHAR(255) NOT NULL, CHANGE firstname firstname VARCHAR(255) NOT NULL, CHANGE lastname lastname VARCHAR(255) NOT NULL, CHANGE old_id old_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE offer CHANGE is_url is_url TINYINT(1) DEFAULT NULL');
$this->addSql('ALTER TABLE post DROP FOREIGN KEY FK_5A8A6C8D3243BB18');
$this->addSql('DROP INDEX IDX_5A8A6C8D3243BB18 ON post');
$this->addSql('ALTER TABLE post DROP hotel_id');
$this->addSql('ALTER TABLE stay ADD old_id INT DEFAULT NULL, ADD status VARCHAR(255) NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE campaign DROP FOREIGN KEY FK_1F1512DD5DA0FB8');
$this->addSql('ALTER TABLE answer DROP FOREIGN KEY FK_DADD4A251E27F6BF');
$this->addSql('ALTER TABLE proposal DROP FOREIGN KEY FK_BFE594721E27F6BF');
$this->addSql('ALTER TABLE question DROP FOREIGN KEY FK_B6F7494EB3FE509D');
$this->addSql('DROP TABLE answer');
$this->addSql('DROP TABLE campaign');
$this->addSql('DROP TABLE email_template');
$this->addSql('DROP TABLE proposal');
$this->addSql('DROP TABLE question');
$this->addSql('DROP TABLE survey');
$this->addSql('ALTER TABLE client CHANGE uid uid VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, CHANGE civility civility VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, CHANGE firstname firstname VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, CHANGE lastname lastname VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, CHANGE old_id old_id INT NOT NULL');
$this->addSql('ALTER TABLE offer CHANGE is_url is_url TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE post ADD hotel_id INT NOT NULL');
$this->addSql('ALTER TABLE post ADD CONSTRAINT FK_5A8A6C8D3243BB18 FOREIGN KEY (hotel_id) REFERENCES hotel (id)');
$this->addSql('CREATE INDEX IDX_5A8A6C8D3243BB18 ON post (hotel_id)');
$this->addSql('ALTER TABLE stay DROP old_id, DROP status');
}
}