// <auto-generated />
using System;
using System.Collections.Generic;
using Kyoo.Abstractions.Models;
using Kyoo.Postgresql;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;

namespace Kyoo.Postgresql.Migrations
{
    [DbContext(typeof(PostgresContext))]
    [Migration("20210801171641_Triggers")]
    partial class Triggers
    {
	    /// <inheritdoc />
        protected override void BuildTargetModel(ModelBuilder modelBuilder)
        {
#pragma warning disable 612, 618
            modelBuilder
                .HasPostgresEnum(null, "item_type", new[] { "show", "movie", "collection" })
                .HasPostgresEnum(null, "status", new[] { "unknown", "finished", "airing", "planned" })
                .HasPostgresEnum(null, "stream_type", new[] { "unknown", "video", "audio", "subtitle", "attachment" })
                .HasAnnotation("Relational:MaxIdentifierLength", 63)
                .HasAnnotation("ProductVersion", "5.0.8")
                .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);

            modelBuilder.Entity("Kyoo.Models.Collection", b =>
                {
                    b.Property<int>("ID")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer")
                        .HasColumnName("id")
                        .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);

                    b.Property<Dictionary<int, string>>("Images")
                        .HasColumnType("jsonb")
                        .HasColumnName("images");

                    b.Property<string>("Name")
                        .HasColumnType("text")
                        .HasColumnName("name");

                    b.Property<string>("Overview")
                        .HasColumnType("text")
                        .HasColumnName("overview");

                    b.Property<string>("Slug")
                        .IsRequired()
                        .HasColumnType("text")
                        .HasColumnName("slug");

                    b.HasKey("ID")
                        .HasName("pk_collections");

                    b.HasIndex("Slug")
                        .IsUnique()
                        .HasDatabaseName("ix_collections_slug");

                    b.ToTable("collections");
                });

            modelBuilder.Entity("Kyoo.Models.Episode", b =>
                {
                    b.Property<int>("ID")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer")
                        .HasColumnName("id")
                        .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);

                    b.Property<int?>("AbsoluteNumber")
                        .HasColumnType("integer")
                        .HasColumnName("absolute_number");

                    b.Property<int?>("EpisodeNumber")
                        .HasColumnType("integer")
                        .HasColumnName("episode_number");

                    b.Property<Dictionary<int, string>>("Images")
                        .HasColumnType("jsonb")
                        .HasColumnName("images");

                    b.Property<string>("Overview")
                        .HasColumnType("text")
                        .HasColumnName("overview");

                    b.Property<string>("Path")
                        .HasColumnType("text")
                        .HasColumnName("path");

                    b.Property<DateTime?>("ReleaseDate")
                        .HasColumnType("timestamp without time zone")
                        .HasColumnName("release_date");

                    b.Property<int?>("SeasonID")
                        .HasColumnType("integer")
                        .HasColumnName("season_id");

                    b.Property<int?>("SeasonNumber")
                        .HasColumnType("integer")
                        .HasColumnName("season_number");

                    b.Property<int>("ShowID")
                        .HasColumnType("integer")
                        .HasColumnName("show_id");

                    b.Property<string>("Slug")
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("text")
                        .HasColumnName("slug");

                    b.Property<string>("Title")
                        .HasColumnType("text")
                        .HasColumnName("title");

                    b.HasKey("ID")
                        .HasName("pk_episodes");

                    b.HasIndex("SeasonID")
                        .HasDatabaseName("ix_episodes_season_id");

                    b.HasIndex("Slug")
                        .IsUnique()
                        .HasDatabaseName("ix_episodes_slug");

                    b.HasIndex("ShowID", "SeasonNumber", "EpisodeNumber", "AbsoluteNumber")
                        .IsUnique()
                        .HasDatabaseName("ix_episodes_show_id_season_number_episode_number_absolute_numb");

                    b.ToTable("episodes");
                });

            modelBuilder.Entity("Kyoo.Models.Genre", b =>
                {
                    b.Property<int>("ID")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer")
                        .HasColumnName("id")
                        .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);

                    b.Property<string>("Name")
                        .HasColumnType("text")
                        .HasColumnName("name");

                    b.Property<string>("Slug")
                        .IsRequired()
                        .HasColumnType("text")
                        .HasColumnName("slug");

                    b.HasKey("ID")
                        .HasName("pk_genres");

                    b.HasIndex("Slug")
                        .IsUnique()
                        .HasDatabaseName("ix_genres_slug");

                    b.ToTable("genres");
                });

            modelBuilder.Entity("Kyoo.Models.Library", b =>
                {
                    b.Property<int>("ID")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer")
                        .HasColumnName("id")
                        .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);

                    b.Property<string>("Name")
                        .HasColumnType("text")
                        .HasColumnName("name");

                    b.Property<string[]>("Paths")
                        .HasColumnType("text[]")
                        .HasColumnName("paths");

                    b.Property<string>("Slug")
                        .IsRequired()
                        .HasColumnType("text")
                        .HasColumnName("slug");

                    b.HasKey("ID")
                        .HasName("pk_libraries");

                    b.HasIndex("Slug")
                        .IsUnique()
                        .HasDatabaseName("ix_libraries_slug");

                    b.ToTable("libraries");
                });

            modelBuilder.Entity("Kyoo.Models.LibraryItem", b =>
                {
                    b.Property<int>("ID")
                        .HasColumnType("integer")
                        .HasColumnName("id")
                        .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);

                    b.Property<DateTime?>("EndAir")
                        .HasColumnType("timestamp without time zone")
                        .HasColumnName("end_air");

                    b.Property<Dictionary<int, string>>("Images")
                        .HasColumnType("jsonb")
                        .HasColumnName("images");

                    b.Property<string>("Overview")
                        .HasColumnType("text")
                        .HasColumnName("overview");

                    b.Property<string>("Slug")
                        .HasColumnType("text")
                        .HasColumnName("slug");

                    b.Property<DateTime?>("StartAir")
                        .HasColumnType("timestamp without time zone")
                        .HasColumnName("start_air");

                    b.Property<Status?>("Status")
                        .HasColumnType("status")
                        .HasColumnName("status");

                    b.Property<string>("Title")
                        .HasColumnType("text")
                        .HasColumnName("title");

                    b.Property<ItemType>("Type")
                        .HasColumnType("item_type")
                        .HasColumnName("type");

                    b.HasKey("ID")
                        .HasName("pk_library_items");

                    b.ToView("library_items");
                });

            modelBuilder.Entity("Kyoo.Models.People", b =>
                {
                    b.Property<int>("ID")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer")
                        .HasColumnName("id")
                        .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);

                    b.Property<Dictionary<int, string>>("Images")
                        .HasColumnType("jsonb")
                        .HasColumnName("images");

                    b.Property<string>("Name")
                        .HasColumnType("text")
                        .HasColumnName("name");

                    b.Property<string>("Slug")
                        .IsRequired()
                        .HasColumnType("text")
                        .HasColumnName("slug");

                    b.HasKey("ID")
                        .HasName("pk_people");

                    b.HasIndex("Slug")
                        .IsUnique()
                        .HasDatabaseName("ix_people_slug");

                    b.ToTable("people");
                });

            modelBuilder.Entity("Kyoo.Models.PeopleRole", b =>
                {
                    b.Property<int>("ID")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer")
                        .HasColumnName("id")
                        .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);

                    b.Property<int>("PeopleID")
                        .HasColumnType("integer")
                        .HasColumnName("people_id");

                    b.Property<string>("Role")
                        .HasColumnType("text")
                        .HasColumnName("role");

                    b.Property<int>("ShowID")
                        .HasColumnType("integer")
                        .HasColumnName("show_id");

                    b.Property<string>("Type")
                        .HasColumnType("text")
                        .HasColumnName("type");

                    b.HasKey("ID")
                        .HasName("pk_people_roles");

                    b.HasIndex("PeopleID")
                        .HasDatabaseName("ix_people_roles_people_id");

                    b.HasIndex("ShowID")
                        .HasDatabaseName("ix_people_roles_show_id");

                    b.ToTable("people_roles");
                });

            modelBuilder.Entity("Kyoo.Models.Provider", b =>
                {
                    b.Property<int>("ID")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer")
                        .HasColumnName("id")
                        .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);

                    b.Property<Dictionary<int, string>>("Images")
                        .HasColumnType("jsonb")
                        .HasColumnName("images");

                    b.Property<string>("Name")
                        .HasColumnType("text")
                        .HasColumnName("name");

                    b.Property<string>("Slug")
                        .IsRequired()
                        .HasColumnType("text")
                        .HasColumnName("slug");

                    b.HasKey("ID")
                        .HasName("pk_providers");

                    b.HasIndex("Slug")
                        .IsUnique()
                        .HasDatabaseName("ix_providers_slug");

                    b.ToTable("providers");
                });

            modelBuilder.Entity("Kyoo.Models.Season", b =>
                {
                    b.Property<int>("ID")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer")
                        .HasColumnName("id")
                        .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);

                    b.Property<DateTime?>("EndDate")
                        .HasColumnType("timestamp without time zone")
                        .HasColumnName("end_date");

                    b.Property<Dictionary<int, string>>("Images")
                        .HasColumnType("jsonb")
                        .HasColumnName("images");

                    b.Property<string>("Overview")
                        .HasColumnType("text")
                        .HasColumnName("overview");

                    b.Property<int>("SeasonNumber")
                        .HasColumnType("integer")
                        .HasColumnName("season_number");

                    b.Property<int>("ShowID")
                        .HasColumnType("integer")
                        .HasColumnName("show_id");

                    b.Property<string>("Slug")
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("text")
                        .HasColumnName("slug");

                    b.Property<DateTime?>("StartDate")
                        .HasColumnType("timestamp without time zone")
                        .HasColumnName("start_date");

                    b.Property<string>("Title")
                        .HasColumnType("text")
                        .HasColumnName("title");

                    b.HasKey("ID")
                        .HasName("pk_seasons");

                    b.HasIndex("Slug")
                        .IsUnique()
                        .HasDatabaseName("ix_seasons_slug");

                    b.HasIndex("ShowID", "SeasonNumber")
                        .IsUnique()
                        .HasDatabaseName("ix_seasons_show_id_season_number");

                    b.ToTable("seasons");
                });

            modelBuilder.Entity("Kyoo.Models.Show", b =>
                {
                    b.Property<int>("ID")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer")
                        .HasColumnName("id")
                        .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);

                    b.Property<string[]>("Aliases")
                        .HasColumnType("text[]")
                        .HasColumnName("aliases");

                    b.Property<DateTime?>("EndAir")
                        .HasColumnType("timestamp without time zone")
                        .HasColumnName("end_air");

                    b.Property<Dictionary<int, string>>("Images")
                        .HasColumnType("jsonb")
                        .HasColumnName("images");

                    b.Property<bool>("IsMovie")
                        .HasColumnType("boolean")
                        .HasColumnName("is_movie");

                    b.Property<string>("Overview")
                        .HasColumnType("text")
                        .HasColumnName("overview");

                    b.Property<string>("Path")
                        .HasColumnType("text")
                        .HasColumnName("path");

                    b.Property<string>("Slug")
                        .IsRequired()
                        .HasColumnType("text")
                        .HasColumnName("slug");

                    b.Property<DateTime?>("StartAir")
                        .HasColumnType("timestamp without time zone")
                        .HasColumnName("start_air");

                    b.Property<Status>("Status")
                        .HasColumnType("status")
                        .HasColumnName("status");

                    b.Property<int?>("StudioID")
                        .HasColumnType("integer")
                        .HasColumnName("studio_id");

                    b.Property<string>("Title")
                        .HasColumnType("text")
                        .HasColumnName("title");

                    b.HasKey("ID")
                        .HasName("pk_shows");

                    b.HasIndex("Slug")
                        .IsUnique()
                        .HasDatabaseName("ix_shows_slug");

                    b.HasIndex("StudioID")
                        .HasDatabaseName("ix_shows_studio_id");

                    b.ToTable("shows");
                });

            modelBuilder.Entity("Kyoo.Models.Studio", b =>
                {
                    b.Property<int>("ID")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer")
                        .HasColumnName("id")
                        .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);

                    b.Property<string>("Name")
                        .HasColumnType("text")
                        .HasColumnName("name");

                    b.Property<string>("Slug")
                        .IsRequired()
                        .HasColumnType("text")
                        .HasColumnName("slug");

                    b.HasKey("ID")
                        .HasName("pk_studios");

                    b.HasIndex("Slug")
                        .IsUnique()
                        .HasDatabaseName("ix_studios_slug");

                    b.ToTable("studios");
                });

            modelBuilder.Entity("Kyoo.Models.Track", b =>
                {
                    b.Property<int>("ID")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer")
                        .HasColumnName("id")
                        .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);

                    b.Property<string>("Codec")
                        .HasColumnType("text")
                        .HasColumnName("codec");

                    b.Property<int>("EpisodeID")
                        .HasColumnType("integer")
                        .HasColumnName("episode_id");

                    b.Property<bool>("IsDefault")
                        .HasColumnType("boolean")
                        .HasColumnName("is_default");

                    b.Property<bool>("IsExternal")
                        .HasColumnType("boolean")
                        .HasColumnName("is_external");

                    b.Property<bool>("IsForced")
                        .HasColumnType("boolean")
                        .HasColumnName("is_forced");

                    b.Property<string>("Language")
                        .HasColumnType("text")
                        .HasColumnName("language");

                    b.Property<string>("Path")
                        .HasColumnType("text")
                        .HasColumnName("path");

                    b.Property<string>("Slug")
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("text")
                        .HasColumnName("slug");

                    b.Property<string>("Title")
                        .HasColumnType("text")
                        .HasColumnName("title");

                    b.Property<int>("TrackIndex")
                        .HasColumnType("integer")
                        .HasColumnName("track_index");

                    b.Property<StreamType>("Type")
                        .HasColumnType("stream_type")
                        .HasColumnName("type");

                    b.HasKey("ID")
                        .HasName("pk_tracks");

                    b.HasIndex("Slug")
                        .IsUnique()
                        .HasDatabaseName("ix_tracks_slug");

                    b.HasIndex("EpisodeID", "Type", "Language", "TrackIndex", "IsForced")
                        .IsUnique()
                        .HasDatabaseName("ix_tracks_episode_id_type_language_track_index_is_forced");

                    b.ToTable("tracks");
                });

            modelBuilder.Entity("Kyoo.Models.User", b =>
                {
                    b.Property<int>("ID")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer")
                        .HasColumnName("id")
                        .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);

                    b.Property<string>("Email")
                        .HasColumnType("text")
                        .HasColumnName("email");

                    b.Property<Dictionary<string, string>>("ExtraData")
                        .HasColumnType("jsonb")
                        .HasColumnName("extra_data");

                    b.Property<Dictionary<int, string>>("Images")
                        .HasColumnType("jsonb")
                        .HasColumnName("images");

                    b.Property<string>("Password")
                        .HasColumnType("text")
                        .HasColumnName("password");

                    b.Property<string[]>("Permissions")
                        .HasColumnType("text[]")
                        .HasColumnName("permissions");

                    b.Property<string>("Slug")
                        .IsRequired()
                        .HasColumnType("text")
                        .HasColumnName("slug");

                    b.Property<string>("Username")
                        .HasColumnType("text")
                        .HasColumnName("username");

                    b.HasKey("ID")
                        .HasName("pk_users");

                    b.HasIndex("Slug")
                        .IsUnique()
                        .HasDatabaseName("ix_users_slug");

                    b.ToTable("users");
                });

            modelBuilder.Entity("Kyoo.Models.WatchedEpisode", b =>
                {
                    b.Property<int>("UserID")
                        .HasColumnType("integer")
                        .HasColumnName("user_id");

                    b.Property<int>("EpisodeID")
                        .HasColumnType("integer")
                        .HasColumnName("episode_id");

                    b.Property<int>("WatchedPercentage")
                        .HasColumnType("integer")
                        .HasColumnName("watched_percentage");

                    b.HasKey("UserID", "EpisodeID")
                        .HasName("pk_watched_episodes");

                    b.HasIndex("EpisodeID")
                        .HasDatabaseName("ix_watched_episodes_episode_id");

                    b.ToTable("watched_episodes");
                });

            modelBuilder.Entity("ShowUser", b =>
                {
                    b.Property<int>("UsersID")
                        .HasColumnType("integer")
                        .HasColumnName("users_id");

                    b.Property<int>("WatchedID")
                        .HasColumnType("integer")
                        .HasColumnName("watched_id");

                    b.HasKey("UsersID", "WatchedID")
                        .HasName("pk_link_user_show");

                    b.HasIndex("WatchedID")
                        .HasDatabaseName("ix_link_user_show_watched_id");

                    b.ToTable("link_user_show");
                });

            modelBuilder.Entity("collection_metadata_id", b =>
                {
                    b.Property<int>("ResourceID")
                        .HasColumnType("integer")
                        .HasColumnName("resource_id");

                    b.Property<int>("ProviderID")
                        .HasColumnType("integer")
                        .HasColumnName("provider_id");

                    b.Property<string>("DataID")
                        .HasColumnType("text")
                        .HasColumnName("data_id");

                    b.Property<string>("Link")
                        .HasColumnType("text")
                        .HasColumnName("link");

                    b.HasKey("ResourceID", "ProviderID")
                        .HasName("pk_collection_metadata_id");

                    b.HasIndex("ProviderID")
                        .HasDatabaseName("ix_collection_metadata_id_provider_id");

                    b.ToTable("collection_metadata_id");
                });

            modelBuilder.Entity("episode_metadata_id", b =>
                {
                    b.Property<int>("ResourceID")
                        .HasColumnType("integer")
                        .HasColumnName("resource_id");

                    b.Property<int>("ProviderID")
                        .HasColumnType("integer")
                        .HasColumnName("provider_id");

                    b.Property<string>("DataID")
                        .HasColumnType("text")
                        .HasColumnName("data_id");

                    b.Property<string>("Link")
                        .HasColumnType("text")
                        .HasColumnName("link");

                    b.HasKey("ResourceID", "ProviderID")
                        .HasName("pk_episode_metadata_id");

                    b.HasIndex("ProviderID")
                        .HasDatabaseName("ix_episode_metadata_id_provider_id");

                    b.ToTable("episode_metadata_id");
                });

            modelBuilder.Entity("link_collection_show", b =>
                {
                    b.Property<int>("collection_id")
                        .HasColumnType("integer")
                        .HasColumnName("collection_id");

                    b.Property<int>("show_id")
                        .HasColumnType("integer")
                        .HasColumnName("show_id");

                    b.HasKey("collection_id", "show_id")
                        .HasName("pk_link_collection_show");

                    b.HasIndex("show_id")
                        .HasDatabaseName("ix_link_collection_show_show_id");

                    b.ToTable("link_collection_show");
                });

            modelBuilder.Entity("link_library_collection", b =>
                {
                    b.Property<int>("collection_id")
                        .HasColumnType("integer")
                        .HasColumnName("collection_id");

                    b.Property<int>("library_id")
                        .HasColumnType("integer")
                        .HasColumnName("library_id");

                    b.HasKey("collection_id", "library_id")
                        .HasName("pk_link_library_collection");

                    b.HasIndex("library_id")
                        .HasDatabaseName("ix_link_library_collection_library_id");

                    b.ToTable("link_library_collection");
                });

            modelBuilder.Entity("link_library_provider", b =>
                {
                    b.Property<int>("library_id")
                        .HasColumnType("integer")
                        .HasColumnName("library_id");

                    b.Property<int>("provider_id")
                        .HasColumnType("integer")
                        .HasColumnName("provider_id");

                    b.HasKey("library_id", "provider_id")
                        .HasName("pk_link_library_provider");

                    b.HasIndex("provider_id")
                        .HasDatabaseName("ix_link_library_provider_provider_id");

                    b.ToTable("link_library_provider");
                });

            modelBuilder.Entity("link_library_show", b =>
                {
                    b.Property<int>("library_id")
                        .HasColumnType("integer")
                        .HasColumnName("library_id");

                    b.Property<int>("show_id")
                        .HasColumnType("integer")
                        .HasColumnName("show_id");

                    b.HasKey("library_id", "show_id")
                        .HasName("pk_link_library_show");

                    b.HasIndex("show_id")
                        .HasDatabaseName("ix_link_library_show_show_id");

                    b.ToTable("link_library_show");
                });

            modelBuilder.Entity("link_show_genre", b =>
                {
                    b.Property<int>("genre_id")
                        .HasColumnType("integer")
                        .HasColumnName("genre_id");

                    b.Property<int>("show_id")
                        .HasColumnType("integer")
                        .HasColumnName("show_id");

                    b.HasKey("genre_id", "show_id")
                        .HasName("pk_link_show_genre");

                    b.HasIndex("show_id")
                        .HasDatabaseName("ix_link_show_genre_show_id");

                    b.ToTable("link_show_genre");
                });

            modelBuilder.Entity("people_metadata_id", b =>
                {
                    b.Property<int>("ResourceID")
                        .HasColumnType("integer")
                        .HasColumnName("resource_id");

                    b.Property<int>("ProviderID")
                        .HasColumnType("integer")
                        .HasColumnName("provider_id");

                    b.Property<string>("DataID")
                        .HasColumnType("text")
                        .HasColumnName("data_id");

                    b.Property<string>("Link")
                        .HasColumnType("text")
                        .HasColumnName("link");

                    b.HasKey("ResourceID", "ProviderID")
                        .HasName("pk_people_metadata_id");

                    b.HasIndex("ProviderID")
                        .HasDatabaseName("ix_people_metadata_id_provider_id");

                    b.ToTable("people_metadata_id");
                });

            modelBuilder.Entity("season_metadata_id", b =>
                {
                    b.Property<int>("ResourceID")
                        .HasColumnType("integer")
                        .HasColumnName("resource_id");

                    b.Property<int>("ProviderID")
                        .HasColumnType("integer")
                        .HasColumnName("provider_id");

                    b.Property<string>("DataID")
                        .HasColumnType("text")
                        .HasColumnName("data_id");

                    b.Property<string>("Link")
                        .HasColumnType("text")
                        .HasColumnName("link");

                    b.HasKey("ResourceID", "ProviderID")
                        .HasName("pk_season_metadata_id");

                    b.HasIndex("ProviderID")
                        .HasDatabaseName("ix_season_metadata_id_provider_id");

                    b.ToTable("season_metadata_id");
                });

            modelBuilder.Entity("show_metadata_id", b =>
                {
                    b.Property<int>("ResourceID")
                        .HasColumnType("integer")
                        .HasColumnName("resource_id");

                    b.Property<int>("ProviderID")
                        .HasColumnType("integer")
                        .HasColumnName("provider_id");

                    b.Property<string>("DataID")
                        .HasColumnType("text")
                        .HasColumnName("data_id");

                    b.Property<string>("Link")
                        .HasColumnType("text")
                        .HasColumnName("link");

                    b.HasKey("ResourceID", "ProviderID")
                        .HasName("pk_show_metadata_id");

                    b.HasIndex("ProviderID")
                        .HasDatabaseName("ix_show_metadata_id_provider_id");

                    b.ToTable("show_metadata_id");
                });

            modelBuilder.Entity("studio_metadata_id", b =>
                {
                    b.Property<int>("ResourceID")
                        .HasColumnType("integer")
                        .HasColumnName("resource_id");

                    b.Property<int>("ProviderID")
                        .HasColumnType("integer")
                        .HasColumnName("provider_id");

                    b.Property<string>("DataID")
                        .HasColumnType("text")
                        .HasColumnName("data_id");

                    b.Property<string>("Link")
                        .HasColumnType("text")
                        .HasColumnName("link");

                    b.HasKey("ResourceID", "ProviderID")
                        .HasName("pk_studio_metadata_id");

                    b.HasIndex("ProviderID")
                        .HasDatabaseName("ix_studio_metadata_id_provider_id");

                    b.ToTable("studio_metadata_id");
                });

            modelBuilder.Entity("Kyoo.Models.Episode", b =>
                {
                    b.HasOne("Kyoo.Models.Season", "Season")
                        .WithMany("Episodes")
                        .HasForeignKey("SeasonID")
                        .HasConstraintName("fk_episodes_seasons_season_id")
                        .OnDelete(DeleteBehavior.Cascade);

                    b.HasOne("Kyoo.Models.Show", "Show")
                        .WithMany("Episodes")
                        .HasForeignKey("ShowID")
                        .HasConstraintName("fk_episodes_shows_show_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Season");

                    b.Navigation("Show");
                });

            modelBuilder.Entity("Kyoo.Models.PeopleRole", b =>
                {
                    b.HasOne("Kyoo.Models.People", "People")
                        .WithMany("Roles")
                        .HasForeignKey("PeopleID")
                        .HasConstraintName("fk_people_roles_people_people_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("Kyoo.Models.Show", "Show")
                        .WithMany("People")
                        .HasForeignKey("ShowID")
                        .HasConstraintName("fk_people_roles_shows_show_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("People");

                    b.Navigation("Show");
                });

            modelBuilder.Entity("Kyoo.Models.Season", b =>
                {
                    b.HasOne("Kyoo.Models.Show", "Show")
                        .WithMany("Seasons")
                        .HasForeignKey("ShowID")
                        .HasConstraintName("fk_seasons_shows_show_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Show");
                });

            modelBuilder.Entity("Kyoo.Models.Show", b =>
                {
                    b.HasOne("Kyoo.Models.Studio", "Studio")
                        .WithMany("Shows")
                        .HasForeignKey("StudioID")
                        .HasConstraintName("fk_shows_studios_studio_id")
                        .OnDelete(DeleteBehavior.SetNull);

                    b.Navigation("Studio");
                });

            modelBuilder.Entity("Kyoo.Models.Track", b =>
                {
                    b.HasOne("Kyoo.Models.Episode", "Episode")
                        .WithMany("Tracks")
                        .HasForeignKey("EpisodeID")
                        .HasConstraintName("fk_tracks_episodes_episode_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Episode");
                });

            modelBuilder.Entity("Kyoo.Models.WatchedEpisode", b =>
                {
                    b.HasOne("Kyoo.Models.Episode", "Episode")
                        .WithMany()
                        .HasForeignKey("EpisodeID")
                        .HasConstraintName("fk_watched_episodes_episodes_episode_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("Kyoo.Models.User", null)
                        .WithMany("CurrentlyWatching")
                        .HasForeignKey("UserID")
                        .HasConstraintName("fk_watched_episodes_users_user_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Episode");
                });

            modelBuilder.Entity("ShowUser", b =>
                {
                    b.HasOne("Kyoo.Models.User", null)
                        .WithMany()
                        .HasForeignKey("UsersID")
                        .HasConstraintName("fk_link_user_show_users_users_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("Kyoo.Models.Show", null)
                        .WithMany()
                        .HasForeignKey("WatchedID")
                        .HasConstraintName("fk_link_user_show_shows_watched_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();
                });

            modelBuilder.Entity("collection_metadata_id", b =>
                {
                    b.HasOne("Kyoo.Models.Provider", "Provider")
                        .WithMany()
                        .HasForeignKey("ProviderID")
                        .HasConstraintName("fk_collection_metadata_id_providers_provider_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("Kyoo.Models.Collection", null)
                        .WithMany("ExternalIDs")
                        .HasForeignKey("ResourceID")
                        .HasConstraintName("fk_collection_metadata_id_collections_collection_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Provider");
                });

            modelBuilder.Entity("episode_metadata_id", b =>
                {
                    b.HasOne("Kyoo.Models.Provider", "Provider")
                        .WithMany()
                        .HasForeignKey("ProviderID")
                        .HasConstraintName("fk_episode_metadata_id_providers_provider_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("Kyoo.Models.Episode", null)
                        .WithMany("ExternalIDs")
                        .HasForeignKey("ResourceID")
                        .HasConstraintName("fk_episode_metadata_id_episodes_episode_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Provider");
                });

            modelBuilder.Entity("link_collection_show", b =>
                {
                    b.HasOne("Kyoo.Models.Collection", null)
                        .WithMany()
                        .HasForeignKey("collection_id")
                        .HasConstraintName("fk_link_collection_show_collections_collection_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("Kyoo.Models.Show", null)
                        .WithMany()
                        .HasForeignKey("show_id")
                        .HasConstraintName("fk_link_collection_show_shows_show_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();
                });

            modelBuilder.Entity("link_library_collection", b =>
                {
                    b.HasOne("Kyoo.Models.Collection", null)
                        .WithMany()
                        .HasForeignKey("collection_id")
                        .HasConstraintName("fk_link_library_collection_collections_collection_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("Kyoo.Models.Library", null)
                        .WithMany()
                        .HasForeignKey("library_id")
                        .HasConstraintName("fk_link_library_collection_libraries_library_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();
                });

            modelBuilder.Entity("link_library_provider", b =>
                {
                    b.HasOne("Kyoo.Models.Library", null)
                        .WithMany()
                        .HasForeignKey("library_id")
                        .HasConstraintName("fk_link_library_provider_libraries_library_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("Kyoo.Models.Provider", null)
                        .WithMany()
                        .HasForeignKey("provider_id")
                        .HasConstraintName("fk_link_library_provider_providers_provider_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();
                });

            modelBuilder.Entity("link_library_show", b =>
                {
                    b.HasOne("Kyoo.Models.Library", null)
                        .WithMany()
                        .HasForeignKey("library_id")
                        .HasConstraintName("fk_link_library_show_libraries_library_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("Kyoo.Models.Show", null)
                        .WithMany()
                        .HasForeignKey("show_id")
                        .HasConstraintName("fk_link_library_show_shows_show_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();
                });

            modelBuilder.Entity("link_show_genre", b =>
                {
                    b.HasOne("Kyoo.Models.Genre", null)
                        .WithMany()
                        .HasForeignKey("genre_id")
                        .HasConstraintName("fk_link_show_genre_genres_genre_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("Kyoo.Models.Show", null)
                        .WithMany()
                        .HasForeignKey("show_id")
                        .HasConstraintName("fk_link_show_genre_shows_show_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();
                });

            modelBuilder.Entity("people_metadata_id", b =>
                {
                    b.HasOne("Kyoo.Models.Provider", "Provider")
                        .WithMany()
                        .HasForeignKey("ProviderID")
                        .HasConstraintName("fk_people_metadata_id_providers_provider_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("Kyoo.Models.People", null)
                        .WithMany("ExternalIDs")
                        .HasForeignKey("ResourceID")
                        .HasConstraintName("fk_people_metadata_id_people_people_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Provider");
                });

            modelBuilder.Entity("season_metadata_id", b =>
                {
                    b.HasOne("Kyoo.Models.Provider", "Provider")
                        .WithMany()
                        .HasForeignKey("ProviderID")
                        .HasConstraintName("fk_season_metadata_id_providers_provider_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("Kyoo.Models.Season", null)
                        .WithMany("ExternalIDs")
                        .HasForeignKey("ResourceID")
                        .HasConstraintName("fk_season_metadata_id_seasons_season_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Provider");
                });

            modelBuilder.Entity("show_metadata_id", b =>
                {
                    b.HasOne("Kyoo.Models.Provider", "Provider")
                        .WithMany()
                        .HasForeignKey("ProviderID")
                        .HasConstraintName("fk_show_metadata_id_providers_provider_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("Kyoo.Models.Show", null)
                        .WithMany("ExternalIDs")
                        .HasForeignKey("ResourceID")
                        .HasConstraintName("fk_show_metadata_id_shows_show_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Provider");
                });

            modelBuilder.Entity("studio_metadata_id", b =>
                {
                    b.HasOne("Kyoo.Models.Provider", "Provider")
                        .WithMany()
                        .HasForeignKey("ProviderID")
                        .HasConstraintName("fk_studio_metadata_id_providers_provider_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("Kyoo.Models.Studio", null)
                        .WithMany("ExternalIDs")
                        .HasForeignKey("ResourceID")
                        .HasConstraintName("fk_studio_metadata_id_studios_studio_id")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Provider");
                });

            modelBuilder.Entity("Kyoo.Models.Collection", b =>
                {
                    b.Navigation("ExternalIDs");
                });

            modelBuilder.Entity("Kyoo.Models.Episode", b =>
                {
                    b.Navigation("ExternalIDs");

                    b.Navigation("Tracks");
                });

            modelBuilder.Entity("Kyoo.Models.People", b =>
                {
                    b.Navigation("ExternalIDs");

                    b.Navigation("Roles");
                });

            modelBuilder.Entity("Kyoo.Models.Season", b =>
                {
                    b.Navigation("Episodes");

                    b.Navigation("ExternalIDs");
                });

            modelBuilder.Entity("Kyoo.Models.Show", b =>
                {
                    b.Navigation("Episodes");

                    b.Navigation("ExternalIDs");

                    b.Navigation("People");

                    b.Navigation("Seasons");
                });

            modelBuilder.Entity("Kyoo.Models.Studio", b =>
                {
                    b.Navigation("ExternalIDs");

                    b.Navigation("Shows");
                });

            modelBuilder.Entity("Kyoo.Models.User", b =>
                {
                    b.Navigation("CurrentlyWatching");
                });
#pragma warning restore 612, 618
        }
    }
}
