<?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 Version20211202103343 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 contact (id INT AUTO_INCREMENT NOT NULL, mail VARCHAR(255) DEFAULT NULL, firstname VARCHAR(255) DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, website VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE movie (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) NOT NULL, realised_by VARCHAR(255) NOT NULL, content LONGTEXT NOT NULL, on_display TINYINT(1) NOT NULL, file VARCHAR(255) DEFAULT NULL, duration DATE NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', update_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', is_published TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE movie_movie_category (movie_id INT NOT NULL, movie_category_id INT NOT NULL, INDEX IDX_F9DC16648F93B6FC (movie_id), INDEX IDX_F9DC16643DC01115 (movie_category_id), PRIMARY KEY(movie_id, movie_category_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE movie_category (id INT AUTO_INCREMENT NOT NULL, label VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE note (id INT AUTO_INCREMENT NOT NULL, id_user_id INT NOT NULL, id_movie_id INT NOT NULL, note_desc VARCHAR(255) DEFAULT NULL, note INT DEFAULT NULL, INDEX IDX_CFBDFA1479F37AE5 (id_user_id), INDEX IDX_CFBDFA14DF485A69 (id_movie_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE reservation (id INT AUTO_INCREMENT NOT NULL, id_user_id INT NOT NULL, id_session_id INT NOT NULL, INDEX IDX_42C8495579F37AE5 (id_user_id), INDEX IDX_42C84955C4B56C08 (id_session_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE session (id INT AUTO_INCREMENT NOT NULL, id_movie_id INT NOT NULL, date DATE NOT NULL, number_d INT NOT NULL, INDEX IDX_D044D5D4DF485A69 (id_movie_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE `user` (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(180) NOT NULL, roles LONGTEXT NOT NULL COMMENT \'(DC2Type:json)\', password VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_8D93D649E7927C74 (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE movie_movie_category ADD CONSTRAINT FK_F9DC16648F93B6FC FOREIGN KEY (movie_id) REFERENCES movie (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE movie_movie_category ADD CONSTRAINT FK_F9DC16643DC01115 FOREIGN KEY (movie_category_id) REFERENCES movie_category (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE note ADD CONSTRAINT FK_CFBDFA1479F37AE5 FOREIGN KEY (id_user_id) REFERENCES `user` (id)');
$this->addSql('ALTER TABLE note ADD CONSTRAINT FK_CFBDFA14DF485A69 FOREIGN KEY (id_movie_id) REFERENCES movie (id)');
$this->addSql('ALTER TABLE reservation ADD CONSTRAINT FK_42C8495579F37AE5 FOREIGN KEY (id_user_id) REFERENCES `user` (id)');
$this->addSql('ALTER TABLE reservation ADD CONSTRAINT FK_42C84955C4B56C08 FOREIGN KEY (id_session_id) REFERENCES session (id)');
$this->addSql('ALTER TABLE session ADD CONSTRAINT FK_D044D5D4DF485A69 FOREIGN KEY (id_movie_id) REFERENCES movie (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE movie_movie_category DROP FOREIGN KEY FK_F9DC16648F93B6FC');
$this->addSql('ALTER TABLE note DROP FOREIGN KEY FK_CFBDFA14DF485A69');
$this->addSql('ALTER TABLE session DROP FOREIGN KEY FK_D044D5D4DF485A69');
$this->addSql('ALTER TABLE movie_movie_category DROP FOREIGN KEY FK_F9DC16643DC01115');
$this->addSql('ALTER TABLE reservation DROP FOREIGN KEY FK_42C84955C4B56C08');
$this->addSql('ALTER TABLE note DROP FOREIGN KEY FK_CFBDFA1479F37AE5');
$this->addSql('ALTER TABLE reservation DROP FOREIGN KEY FK_42C8495579F37AE5');
$this->addSql('DROP TABLE contact');
$this->addSql('DROP TABLE movie');
$this->addSql('DROP TABLE movie_movie_category');
$this->addSql('DROP TABLE movie_category');
$this->addSql('DROP TABLE note');
$this->addSql('DROP TABLE reservation');
$this->addSql('DROP TABLE session');
$this->addSql('DROP TABLE `user`');
}
}