Version20250113132626.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7. * Auto-generated Migration: Please modify to your needs!
  8. */
  9. final class Version20250113132626 extends AbstractMigration
  10. {
  11. public function getDescription(): string
  12. {
  13. return '';
  14. }
  15. public function up(Schema $schema): void
  16. {
  17. // this up() migration is auto-generated, please modify it to your needs
  18. $this->addSql('CREATE SEQUENCE user_list_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  19. $this->addSql('CREATE SEQUENCE user_list_film_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  20. $this->addSql('CREATE TABLE user_list (id INT NOT NULL, viewer_id INT NOT NULL, PRIMARY KEY(id))');
  21. $this->addSql('CREATE INDEX IDX_3E49B4D16C59C752 ON user_list (viewer_id)');
  22. $this->addSql('CREATE TABLE user_list_film (id INT NOT NULL, user_list_id INT DEFAULT NULL, film_id INT NOT NULL, position INT DEFAULT NULL, PRIMARY KEY(id))');
  23. $this->addSql('CREATE INDEX IDX_C76AEC2F65A30881 ON user_list_film (user_list_id)');
  24. $this->addSql('CREATE INDEX IDX_C76AEC2F567F5183 ON user_list_film (film_id)');
  25. $this->addSql('ALTER TABLE user_list ADD CONSTRAINT FK_3E49B4D16C59C752 FOREIGN KEY (viewer_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  26. $this->addSql('ALTER TABLE user_list_film ADD CONSTRAINT FK_C76AEC2F65A30881 FOREIGN KEY (user_list_id) REFERENCES user_list (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  27. $this->addSql('ALTER TABLE user_list_film ADD CONSTRAINT FK_C76AEC2F567F5183 FOREIGN KEY (film_id) REFERENCES film (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  28. }
  29. public function down(Schema $schema): void
  30. {
  31. // this down() migration is auto-generated, please modify it to your needs
  32. $this->addSql('CREATE SCHEMA public');
  33. $this->addSql('DROP SEQUENCE user_list_id_seq CASCADE');
  34. $this->addSql('DROP SEQUENCE user_list_film_id_seq CASCADE');
  35. $this->addSql('ALTER TABLE user_list DROP CONSTRAINT FK_3E49B4D16C59C752');
  36. $this->addSql('ALTER TABLE user_list_film DROP CONSTRAINT FK_C76AEC2F65A30881');
  37. $this->addSql('ALTER TABLE user_list_film DROP CONSTRAINT FK_C76AEC2F567F5183');
  38. $this->addSql('DROP TABLE user_list');
  39. $this->addSql('DROP TABLE user_list_film');
  40. }
  41. }