<?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 Version20210929105419 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 category (id INT AUTO_INCREMENT NOT NULL, parent_id INT DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, picture VARCHAR(255) NOT NULL, INDEX IDX_64C19C1727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE message (id INT AUTO_INCREMENT NOT NULL, client_id INT NOT NULL, hotel_id INT NOT NULL, content LONGTEXT NOT NULL, last_text LONGTEXT DEFAULT NULL, last_date DATETIME DEFAULT NULL, seen TINYINT(1) NOT NULL, admin_seen TINYINT(1) NOT NULL, created_at DATETIME NOT NULL, INDEX IDX_B6BD307F19EB6921 (client_id), INDEX IDX_B6BD307F3243BB18 (hotel_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE offer (id INT AUTO_INCREMENT NOT NULL, hotel_id INT NOT NULL, title VARCHAR(255) NOT NULL, price VARCHAR(255) DEFAULT NULL, picture VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, valid_until DATETIME NOT NULL, is_url TINYINT(1) NOT NULL, url VARCHAR(255) NOT NULL, INDEX IDX_29D6873E3243BB18 (hotel_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE post (id INT AUTO_INCREMENT NOT NULL, category_id INT NOT NULL, title VARCHAR(255) NOT NULL, content LONGTEXT DEFAULT NULL, picture VARCHAR(255) NOT NULL, INDEX IDX_5A8A6C8D12469DE2 (category_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE refresh_tokens (id INT AUTO_INCREMENT NOT NULL, refresh_token VARCHAR(128) NOT NULL, username VARCHAR(255) NOT NULL, valid DATETIME NOT NULL, UNIQUE INDEX UNIQ_9BACE7E1C74F2195 (refresh_token), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE service (id INT AUTO_INCREMENT NOT NULL, hotel_id INT NOT NULL, name VARCHAR(255) NOT NULL, icon VARCHAR(255) NOT NULL, enable TINYINT(1) NOT NULL, INDEX IDX_E19D9AD23243BB18 (hotel_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE slide (id INT AUTO_INCREMENT NOT NULL, slider_id INT NOT NULL, picture VARCHAR(255) NOT NULL, INDEX IDX_72EFEE622CCC9638 (slider_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE slider (id INT AUTO_INCREMENT NOT NULL, hotel_id INT NOT NULL, name VARCHAR(255) NOT NULL, enable TINYINT(1) NOT NULL, initial_slide INT DEFAULT NULL, speed INT DEFAULT NULL, allow_slide_next TINYINT(1) NOT NULL, allow_slide_prev TINYINT(1) NOT NULL, allow_touch_move TINYINT(1) NOT NULL, loop_slides TINYINT(1) NOT NULL, threshold INT NOT NULL, INDEX IDX_CFC710073243BB18 (hotel_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE category ADD CONSTRAINT FK_64C19C1727ACA70 FOREIGN KEY (parent_id) REFERENCES category (id)');
$this->addSql('ALTER TABLE message ADD CONSTRAINT FK_B6BD307F19EB6921 FOREIGN KEY (client_id) REFERENCES client (id)');
$this->addSql('ALTER TABLE message ADD CONSTRAINT FK_B6BD307F3243BB18 FOREIGN KEY (hotel_id) REFERENCES hotel (id)');
$this->addSql('ALTER TABLE offer ADD CONSTRAINT FK_29D6873E3243BB18 FOREIGN KEY (hotel_id) REFERENCES hotel (id)');
$this->addSql('ALTER TABLE post ADD CONSTRAINT FK_5A8A6C8D12469DE2 FOREIGN KEY (category_id) REFERENCES category (id)');
$this->addSql('ALTER TABLE service ADD CONSTRAINT FK_E19D9AD23243BB18 FOREIGN KEY (hotel_id) REFERENCES hotel (id)');
$this->addSql('ALTER TABLE slide ADD CONSTRAINT FK_72EFEE622CCC9638 FOREIGN KEY (slider_id) REFERENCES slider (id)');
$this->addSql('ALTER TABLE slider ADD CONSTRAINT FK_CFC710073243BB18 FOREIGN KEY (hotel_id) REFERENCES hotel (id)');
$this->addSql('ALTER TABLE client CHANGE city city VARCHAR(255) DEFAULT NULL, CHANGE country country VARCHAR(255) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE category DROP FOREIGN KEY FK_64C19C1727ACA70');
$this->addSql('ALTER TABLE post DROP FOREIGN KEY FK_5A8A6C8D12469DE2');
$this->addSql('ALTER TABLE slide DROP FOREIGN KEY FK_72EFEE622CCC9638');
$this->addSql('DROP TABLE category');
$this->addSql('DROP TABLE message');
$this->addSql('DROP TABLE offer');
$this->addSql('DROP TABLE post');
$this->addSql('DROP TABLE refresh_tokens');
$this->addSql('DROP TABLE service');
$this->addSql('DROP TABLE slide');
$this->addSql('DROP TABLE slider');
$this->addSql('ALTER TABLE client CHANGE city city VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, CHANGE country country VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`');
}
}