mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Add watchlist migration
This commit is contained in:
parent
4139362677
commit
948c98f95b
1293
back/src/Kyoo.Postgresql/Migrations/20231129014309_Watchlist.Designer.cs
generated
Normal file
1293
back/src/Kyoo.Postgresql/Migrations/20231129014309_Watchlist.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
174
back/src/Kyoo.Postgresql/Migrations/20231129014309_Watchlist.cs
Normal file
174
back/src/Kyoo.Postgresql/Migrations/20231129014309_Watchlist.cs
Normal file
@ -0,0 +1,174 @@
|
||||
// Kyoo - A portable and vast media library solution.
|
||||
// Copyright (c) Kyoo.
|
||||
//
|
||||
// See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
//
|
||||
// Kyoo is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// Kyoo is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using Kyoo.Abstractions.Models;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Kyoo.Postgresql.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Watchlist : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterDatabase()
|
||||
.Annotation("Npgsql:Enum:genre", "action,adventure,animation,comedy,crime,documentary,drama,family,fantasy,history,horror,music,mystery,romance,science_fiction,thriller,war,western")
|
||||
.Annotation("Npgsql:Enum:status", "unknown,finished,airing,planned")
|
||||
.Annotation("Npgsql:Enum:watch_status", "completed,watching,droped,planned")
|
||||
.OldAnnotation("Npgsql:Enum:genre", "action,adventure,animation,comedy,crime,documentary,drama,family,fantasy,history,horror,music,mystery,romance,science_fiction,thriller,war,western")
|
||||
.OldAnnotation("Npgsql:Enum:status", "unknown,finished,airing,planned");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "episode_watch_status",
|
||||
columns: table => new
|
||||
{
|
||||
user_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
episode_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
added_date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"),
|
||||
played_date = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
||||
status = table.Column<WatchStatus>(type: "watch_status", nullable: false),
|
||||
watched_time = table.Column<int>(type: "integer", nullable: true),
|
||||
watched_percent = table.Column<int>(type: "integer", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_episode_watch_status", x => new { x.user_id, x.episode_id });
|
||||
table.ForeignKey(
|
||||
name: "fk_episode_watch_status_episodes_episode_id",
|
||||
column: x => x.episode_id,
|
||||
principalTable: "episodes",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "fk_episode_watch_status_users_user_id",
|
||||
column: x => x.user_id,
|
||||
principalTable: "users",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "movie_watch_status",
|
||||
columns: table => new
|
||||
{
|
||||
user_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
movie_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
added_date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"),
|
||||
played_date = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
||||
status = table.Column<WatchStatus>(type: "watch_status", nullable: false),
|
||||
watched_time = table.Column<int>(type: "integer", nullable: true),
|
||||
watched_percent = table.Column<int>(type: "integer", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_movie_watch_status", x => new { x.user_id, x.movie_id });
|
||||
table.ForeignKey(
|
||||
name: "fk_movie_watch_status_movies_movie_id",
|
||||
column: x => x.movie_id,
|
||||
principalTable: "movies",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "fk_movie_watch_status_users_user_id",
|
||||
column: x => x.user_id,
|
||||
principalTable: "users",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "show_watch_status",
|
||||
columns: table => new
|
||||
{
|
||||
user_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
show_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
added_date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"),
|
||||
played_date = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
||||
status = table.Column<WatchStatus>(type: "watch_status", nullable: false),
|
||||
unseen_episodes_count = table.Column<int>(type: "integer", nullable: false),
|
||||
next_episode_id = table.Column<Guid>(type: "uuid", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_show_watch_status", x => new { x.user_id, x.show_id });
|
||||
table.ForeignKey(
|
||||
name: "fk_show_watch_status_episodes_next_episode_id",
|
||||
column: x => x.next_episode_id,
|
||||
principalTable: "episodes",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "fk_show_watch_status_shows_show_id",
|
||||
column: x => x.show_id,
|
||||
principalTable: "shows",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "fk_show_watch_status_users_user_id",
|
||||
column: x => x.user_id,
|
||||
principalTable: "users",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_episode_watch_status_episode_id",
|
||||
table: "episode_watch_status",
|
||||
column: "episode_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_movie_watch_status_movie_id",
|
||||
table: "movie_watch_status",
|
||||
column: "movie_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_show_watch_status_next_episode_id",
|
||||
table: "show_watch_status",
|
||||
column: "next_episode_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_show_watch_status_show_id",
|
||||
table: "show_watch_status",
|
||||
column: "show_id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "episode_watch_status");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "movie_watch_status");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "show_watch_status");
|
||||
|
||||
migrationBuilder.AlterDatabase()
|
||||
.Annotation("Npgsql:Enum:genre", "action,adventure,animation,comedy,crime,documentary,drama,family,fantasy,history,horror,music,mystery,romance,science_fiction,thriller,war,western")
|
||||
.Annotation("Npgsql:Enum:status", "unknown,finished,airing,planned")
|
||||
.OldAnnotation("Npgsql:Enum:genre", "action,adventure,animation,comedy,crime,documentary,drama,family,fantasy,history,horror,music,mystery,romance,science_fiction,thriller,war,western")
|
||||
.OldAnnotation("Npgsql:Enum:status", "unknown,finished,airing,planned")
|
||||
.OldAnnotation("Npgsql:Enum:watch_status", "completed,watching,droped,planned");
|
||||
}
|
||||
}
|
||||
}
|
@ -21,6 +21,7 @@ namespace Kyoo.Postgresql.Migrations
|
||||
|
||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "genre", new[] { "action", "adventure", "animation", "comedy", "crime", "documentary", "drama", "family", "fantasy", "history", "horror", "music", "mystery", "romance", "science_fiction", "thriller", "war", "western" });
|
||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "status", new[] { "unknown", "finished", "airing", "planned" });
|
||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "watch_status", new[] { "completed", "watching", "droped", "planned" });
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Kyoo.Abstractions.Models.Collection", b =>
|
||||
@ -148,6 +149,47 @@ namespace Kyoo.Postgresql.Migrations
|
||||
b.ToTable("episodes", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kyoo.Abstractions.Models.EpisodeWatchStatus", b =>
|
||||
{
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
b.Property<Guid?>("EpisodeId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("episode_id");
|
||||
|
||||
b.Property<DateTime>("AddedDate")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("added_date")
|
||||
.HasDefaultValueSql("now() at time zone 'utc'");
|
||||
|
||||
b.Property<DateTime?>("PlayedDate")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("played_date");
|
||||
|
||||
b.Property<WatchStatus>("Status")
|
||||
.HasColumnType("watch_status")
|
||||
.HasColumnName("status");
|
||||
|
||||
b.Property<int?>("WatchedPercent")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("watched_percent");
|
||||
|
||||
b.Property<int?>("WatchedTime")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("watched_time");
|
||||
|
||||
b.HasKey("UserId", "EpisodeId")
|
||||
.HasName("pk_episode_watch_status");
|
||||
|
||||
b.HasIndex("EpisodeId")
|
||||
.HasDatabaseName("ix_episode_watch_status_episode_id");
|
||||
|
||||
b.ToTable("episode_watch_status", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kyoo.Abstractions.Models.Movie", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
@ -242,6 +284,47 @@ namespace Kyoo.Postgresql.Migrations
|
||||
b.ToTable("movies", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kyoo.Abstractions.Models.MovieWatchStatus", b =>
|
||||
{
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
b.Property<Guid>("MovieId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("movie_id");
|
||||
|
||||
b.Property<DateTime>("AddedDate")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("added_date")
|
||||
.HasDefaultValueSql("now() at time zone 'utc'");
|
||||
|
||||
b.Property<DateTime?>("PlayedDate")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("played_date");
|
||||
|
||||
b.Property<WatchStatus>("Status")
|
||||
.HasColumnType("watch_status")
|
||||
.HasColumnName("status");
|
||||
|
||||
b.Property<int?>("WatchedPercent")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("watched_percent");
|
||||
|
||||
b.Property<int?>("WatchedTime")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("watched_time");
|
||||
|
||||
b.HasKey("UserId", "MovieId")
|
||||
.HasName("pk_movie_watch_status");
|
||||
|
||||
b.HasIndex("MovieId")
|
||||
.HasDatabaseName("ix_movie_watch_status_movie_id");
|
||||
|
||||
b.ToTable("movie_watch_status", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kyoo.Abstractions.Models.Season", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
@ -393,6 +476,50 @@ namespace Kyoo.Postgresql.Migrations
|
||||
b.ToTable("shows", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kyoo.Abstractions.Models.ShowWatchStatus", b =>
|
||||
{
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
b.Property<Guid>("ShowId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("show_id");
|
||||
|
||||
b.Property<DateTime>("AddedDate")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("added_date")
|
||||
.HasDefaultValueSql("now() at time zone 'utc'");
|
||||
|
||||
b.Property<Guid>("NextEpisodeId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("next_episode_id");
|
||||
|
||||
b.Property<DateTime?>("PlayedDate")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("played_date");
|
||||
|
||||
b.Property<WatchStatus>("Status")
|
||||
.HasColumnType("watch_status")
|
||||
.HasColumnName("status");
|
||||
|
||||
b.Property<int>("UnseenEpisodesCount")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("unseen_episodes_count");
|
||||
|
||||
b.HasKey("UserId", "ShowId")
|
||||
.HasName("pk_show_watch_status");
|
||||
|
||||
b.HasIndex("NextEpisodeId")
|
||||
.HasDatabaseName("ix_show_watch_status_next_episode_id");
|
||||
|
||||
b.HasIndex("ShowId")
|
||||
.HasDatabaseName("ix_show_watch_status_show_id");
|
||||
|
||||
b.ToTable("show_watch_status", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kyoo.Abstractions.Models.Studio", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
@ -704,6 +831,27 @@ namespace Kyoo.Postgresql.Migrations
|
||||
b.Navigation("Thumbnail");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kyoo.Abstractions.Models.EpisodeWatchStatus", b =>
|
||||
{
|
||||
b.HasOne("Kyoo.Abstractions.Models.Episode", "Episode")
|
||||
.WithMany("Watched")
|
||||
.HasForeignKey("EpisodeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_episode_watch_status_episodes_episode_id");
|
||||
|
||||
b.HasOne("Kyoo.Abstractions.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_episode_watch_status_users_user_id");
|
||||
|
||||
b.Navigation("Episode");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kyoo.Abstractions.Models.Movie", b =>
|
||||
{
|
||||
b.HasOne("Kyoo.Abstractions.Models.Studio", "Studio")
|
||||
@ -799,6 +947,27 @@ namespace Kyoo.Postgresql.Migrations
|
||||
b.Navigation("Thumbnail");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kyoo.Abstractions.Models.MovieWatchStatus", b =>
|
||||
{
|
||||
b.HasOne("Kyoo.Abstractions.Models.Movie", "Movie")
|
||||
.WithMany("Watched")
|
||||
.HasForeignKey("MovieId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_movie_watch_status_movies_movie_id");
|
||||
|
||||
b.HasOne("Kyoo.Abstractions.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_movie_watch_status_users_user_id");
|
||||
|
||||
b.Navigation("Movie");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kyoo.Abstractions.Models.Season", b =>
|
||||
{
|
||||
b.HasOne("Kyoo.Abstractions.Models.Show", "Show")
|
||||
@ -990,6 +1159,36 @@ namespace Kyoo.Postgresql.Migrations
|
||||
b.Navigation("Thumbnail");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kyoo.Abstractions.Models.ShowWatchStatus", b =>
|
||||
{
|
||||
b.HasOne("Kyoo.Abstractions.Models.Episode", "NextEpisode")
|
||||
.WithMany()
|
||||
.HasForeignKey("NextEpisodeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_show_watch_status_episodes_next_episode_id");
|
||||
|
||||
b.HasOne("Kyoo.Abstractions.Models.Show", "Show")
|
||||
.WithMany("Watched")
|
||||
.HasForeignKey("ShowId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_show_watch_status_shows_show_id");
|
||||
|
||||
b.HasOne("Kyoo.Abstractions.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_show_watch_status_users_user_id");
|
||||
|
||||
b.Navigation("NextEpisode");
|
||||
|
||||
b.Navigation("Show");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kyoo.Abstractions.Models.User", b =>
|
||||
{
|
||||
b.OwnsOne("Kyoo.Abstractions.Models.Image", "Logo", b1 =>
|
||||
@ -1055,6 +1254,16 @@ namespace Kyoo.Postgresql.Migrations
|
||||
.HasConstraintName("fk_link_collection_show_shows_show_id");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kyoo.Abstractions.Models.Episode", b =>
|
||||
{
|
||||
b.Navigation("Watched");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kyoo.Abstractions.Models.Movie", b =>
|
||||
{
|
||||
b.Navigation("Watched");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kyoo.Abstractions.Models.Season", b =>
|
||||
{
|
||||
b.Navigation("Episodes");
|
||||
@ -1065,6 +1274,8 @@ namespace Kyoo.Postgresql.Migrations
|
||||
b.Navigation("Episodes");
|
||||
|
||||
b.Navigation("Seasons");
|
||||
|
||||
b.Navigation("Watched");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kyoo.Abstractions.Models.Studio", b =>
|
||||
|
Loading…
x
Reference in New Issue
Block a user