39 lines
1.6 KiB
PHP
39 lines
1.6 KiB
PHP
<?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 Version20260329000001 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 user_movie (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, user_id INT NOT NULL, movie_id INT NOT NULL, PRIMARY KEY (id))');
|
|
$this->addSql('CREATE INDEX IDX_A6B68B33A76ED395 ON user_movie (user_id)');
|
|
$this->addSql('CREATE INDEX IDX_A6B68B338F93B6FC ON user_movie (movie_id)');
|
|
$this->addSql('CREATE UNIQUE INDEX user_movie_unique ON user_movie (user_id, movie_id)');
|
|
$this->addSql('ALTER TABLE user_movie ADD CONSTRAINT FK_A6B68B33A76ED395 FOREIGN KEY (user_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
|
$this->addSql('ALTER TABLE user_movie ADD CONSTRAINT FK_A6B68B338F93B6FC FOREIGN KEY (movie_id) REFERENCES movie (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
// this down() migration is auto-generated, please modify it to your needs
|
|
$this->addSql('ALTER TABLE user_movie DROP CONSTRAINT FK_A6B68B33A76ED395');
|
|
$this->addSql('ALTER TABLE user_movie DROP CONSTRAINT FK_A6B68B338F93B6FC');
|
|
$this->addSql('DROP TABLE user_movie');
|
|
}
|
|
}
|