diff --git a/migrations/Version20260329000001.php b/migrations/Version20260329000001.php new file mode 100644 index 0000000..d2893b9 --- /dev/null +++ b/migrations/Version20260329000001.php @@ -0,0 +1,38 @@ +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'); + } +} diff --git a/src/Entity/UserMovie.php b/src/Entity/UserMovie.php new file mode 100644 index 0000000..bcb3e19 --- /dev/null +++ b/src/Entity/UserMovie.php @@ -0,0 +1,55 @@ +id; + } + + public function getUser(): ?User + { + return $this->user; + } + + public function setUser(?User $user): static + { + $this->user = $user; + + return $this; + } + + public function getMovie(): ?Movie + { + return $this->movie; + } + + public function setMovie(?Movie $movie): static + { + $this->movie = $movie; + + return $this; + } +} diff --git a/src/Repository/UserMovieRepository.php b/src/Repository/UserMovieRepository.php new file mode 100644 index 0000000..746764e --- /dev/null +++ b/src/Repository/UserMovieRepository.php @@ -0,0 +1,20 @@ + + */ +class UserMovieRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, UserMovie::class); + } +}