<?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 Version20210924155047 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 cal_survey (id INT AUTO_INCREMENT NOT NULL, template_id INT DEFAULT NULL, user_id INT DEFAULT NULL, room_id INT DEFAULT NULL, accommodation_id INT DEFAULT NULL, token VARCHAR(255) NOT NULL, status VARCHAR(50) NOT NULL, comment LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_DC0654175DA0FB8 (template_id), INDEX IDX_DC065417A76ED395 (user_id), INDEX IDX_DC06541754177093 (room_id), INDEX IDX_DC0654178F3692CD (accommodation_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE cal_survey_answer (id INT AUTO_INCREMENT NOT NULL, survey_id INT DEFAULT NULL, question_id INT DEFAULT NULL, note INT NOT NULL, INDEX IDX_F54AB686B3FE509D (survey_id), INDEX IDX_F54AB6861E27F6BF (question_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE cal_survey_question (id INT AUTO_INCREMENT NOT NULL, template_id INT DEFAULT NULL, question_id INT DEFAULT NULL, slug VARCHAR(50) NOT NULL, position INT NOT NULL, INDEX IDX_87D637C45DA0FB8 (template_id), UNIQUE INDEX UNIQ_87D637C41E27F6BF (question_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE cal_survey_template (id INT AUTO_INCREMENT NOT NULL, slug VARCHAR(50) NOT NULL, name VARCHAR(50) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE cal_survey ADD CONSTRAINT FK_DC0654175DA0FB8 FOREIGN KEY (template_id) REFERENCES cal_survey_template (id)');
$this->addSql('ALTER TABLE cal_survey ADD CONSTRAINT FK_DC065417A76ED395 FOREIGN KEY (user_id) REFERENCES cal_user (id)');
$this->addSql('ALTER TABLE cal_survey ADD CONSTRAINT FK_DC06541754177093 FOREIGN KEY (room_id) REFERENCES cal_accommodation_room (id)');
$this->addSql('ALTER TABLE cal_survey ADD CONSTRAINT FK_DC0654178F3692CD FOREIGN KEY (accommodation_id) REFERENCES cal_accommodation (id)');
$this->addSql('ALTER TABLE cal_survey_answer ADD CONSTRAINT FK_F54AB686B3FE509D FOREIGN KEY (survey_id) REFERENCES cal_survey (id)');
$this->addSql('ALTER TABLE cal_survey_answer ADD CONSTRAINT FK_F54AB6861E27F6BF FOREIGN KEY (question_id) REFERENCES cal_survey_question (id)');
$this->addSql('ALTER TABLE cal_survey_question ADD CONSTRAINT FK_87D637C45DA0FB8 FOREIGN KEY (template_id) REFERENCES cal_survey_template (id)');
$this->addSql('ALTER TABLE cal_survey_question ADD CONSTRAINT FK_87D637C41E27F6BF FOREIGN KEY (question_id) REFERENCES cal_translation (id)');
$this->addSql('ALTER TABLE cal_inventory ADD survey_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE cal_inventory ADD CONSTRAINT FK_4A4F57D7B3FE509D FOREIGN KEY (survey_id) REFERENCES cal_survey (id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_4A4F57D7B3FE509D ON cal_inventory (survey_id)');
$this->addSql('ALTER TABLE cal_maintenance ADD inventory_id INT DEFAULT NULL, ADD to_be_paid_by VARCHAR(50) NOT NULL');
$this->addSql('ALTER TABLE cal_maintenance ADD CONSTRAINT FK_BE7ADFF9EEA759 FOREIGN KEY (inventory_id) REFERENCES cal_inventory (id)');
$this->addSql('CREATE INDEX IDX_BE7ADFF9EEA759 ON cal_maintenance (inventory_id)');
$this->addSql('ALTER TABLE cal_maintenance_appointment ADD survey_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE cal_maintenance_appointment ADD CONSTRAINT FK_FB1E4445B3FE509D FOREIGN KEY (survey_id) REFERENCES cal_survey (id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_FB1E4445B3FE509D ON cal_maintenance_appointment (survey_id)');
$this->addSql('ALTER TABLE cal_maintenance_quotation ADD invoice_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE cal_maintenance_quotation ADD CONSTRAINT FK_7568E6892989F1FD FOREIGN KEY (invoice_id) REFERENCES cal_maintenance_document (id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_7568E6892989F1FD ON cal_maintenance_quotation (invoice_id)');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE cal_inventory DROP FOREIGN KEY FK_4A4F57D7B3FE509D');
$this->addSql('ALTER TABLE cal_maintenance_appointment DROP FOREIGN KEY FK_FB1E4445B3FE509D');
$this->addSql('ALTER TABLE cal_survey_answer DROP FOREIGN KEY FK_F54AB686B3FE509D');
$this->addSql('ALTER TABLE cal_survey_answer DROP FOREIGN KEY FK_F54AB6861E27F6BF');
$this->addSql('ALTER TABLE cal_survey DROP FOREIGN KEY FK_DC0654175DA0FB8');
$this->addSql('ALTER TABLE cal_survey_question DROP FOREIGN KEY FK_87D637C45DA0FB8');
$this->addSql('DROP TABLE cal_survey');
$this->addSql('DROP TABLE cal_survey_answer');
$this->addSql('DROP TABLE cal_survey_question');
$this->addSql('DROP TABLE cal_survey_template');
$this->addSql('DROP INDEX UNIQ_4A4F57D7B3FE509D ON cal_inventory');
$this->addSql('ALTER TABLE cal_inventory DROP survey_id');
$this->addSql('ALTER TABLE cal_maintenance DROP FOREIGN KEY FK_BE7ADFF9EEA759');
$this->addSql('DROP INDEX IDX_BE7ADFF9EEA759 ON cal_maintenance');
$this->addSql('ALTER TABLE cal_maintenance DROP inventory_id, DROP to_be_paid_by');
$this->addSql('DROP INDEX UNIQ_FB1E4445B3FE509D ON cal_maintenance_appointment');
$this->addSql('ALTER TABLE cal_maintenance_appointment DROP survey_id');
$this->addSql('ALTER TABLE cal_maintenance_quotation DROP FOREIGN KEY FK_7568E6892989F1FD');
$this->addSql('DROP INDEX UNIQ_7568E6892989F1FD ON cal_maintenance_quotation');
$this->addSql('ALTER TABLE cal_maintenance_quotation DROP invoice_id');
}
}