Remove track table

This commit is contained in:
Zoe Roux 2023-07-31 16:00:39 +09:00
parent c69864d0f5
commit e6f263b6de
4 changed files with 2266 additions and 1068 deletions

View File

@ -543,7 +543,7 @@ namespace Kyoo.Postgresql.Migrations
.HasColumnType("integer")
.HasColumnName("track_index");
b.Property<object>("Type")
b.Property<string>("Type")
.HasColumnType("stream_type")
.HasColumnName("type");

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,95 @@
// 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 Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Kyoo.Postgresql.Migrations
{
/// <inheritdoc />
public partial class RemoveTracks : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "tracks");
migrationBuilder.AlterDatabase()
.Annotation("Npgsql:Enum:item_type", "show,movie,collection")
.Annotation("Npgsql:Enum:status", "unknown,finished,airing,planned")
.OldAnnotation("Npgsql:Enum:item_type", "show,movie,collection")
.OldAnnotation("Npgsql:Enum:status", "unknown,finished,airing,planned")
.OldAnnotation("Npgsql:Enum:stream_type", "unknown,video,audio,subtitle");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterDatabase()
.Annotation("Npgsql:Enum:item_type", "show,movie,collection")
.Annotation("Npgsql:Enum:status", "unknown,finished,airing,planned")
.Annotation("Npgsql:Enum:stream_type", "unknown,video,audio,subtitle")
.OldAnnotation("Npgsql:Enum:item_type", "show,movie,collection")
.OldAnnotation("Npgsql:Enum:status", "unknown,finished,airing,planned");
migrationBuilder.CreateTable(
name: "tracks",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
episode_id = table.Column<int>(type: "integer", nullable: false),
codec = table.Column<string>(type: "text", nullable: true),
is_default = table.Column<bool>(type: "boolean", nullable: false),
is_external = table.Column<bool>(type: "boolean", nullable: false),
is_forced = table.Column<bool>(type: "boolean", nullable: false),
language = table.Column<string>(type: "text", nullable: true),
path = table.Column<string>(type: "text", nullable: true),
slug = table.Column<string>(type: "text", nullable: false),
title = table.Column<string>(type: "text", nullable: true),
track_index = table.Column<int>(type: "integer", nullable: false),
type = table.Column<string>(type: "stream_type", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_tracks", x => x.id);
table.ForeignKey(
name: "fk_tracks_episodes_episode_id",
column: x => x.episode_id,
principalTable: "episodes",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "ix_tracks_episode_id_type_language_track_index_is_forced",
table: "tracks",
columns: new[] { "episode_id", "type", "language", "track_index", "is_forced" },
unique: true);
migrationBuilder.CreateIndex(
name: "ix_tracks_slug",
table: "tracks",
column: "slug",
unique: true);
}
}
}

View File

@ -1,12 +1,9 @@
// <auto-generated />
// <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.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
@ -24,7 +21,6 @@ namespace Kyoo.Postgresql.Migrations
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "item_type", new[] { "show", "movie", "collection" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "status", new[] { "unknown", "finished", "airing", "planned" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "stream_type", new[] { "unknown", "video", "audio", "subtitle" });
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Kyoo.Abstractions.Models.Collection", b =>
@ -492,74 +488,6 @@ namespace Kyoo.Postgresql.Migrations
b.ToTable("studios", (string)null);
});
modelBuilder.Entity("Kyoo.Abstractions.Models.Track", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("ID"));
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")
.IsRequired()
.HasColumnType("text")
.HasColumnName("slug");
b.Property<string>("Title")
.HasColumnType("text")
.HasColumnName("title");
b.Property<int>("TrackIndex")
.HasColumnType("integer")
.HasColumnName("track_index");
b.Property<object>("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", (string)null);
});
modelBuilder.Entity("Kyoo.Abstractions.Models.User", b =>
{
b.Property<int>("ID")
@ -971,18 +899,6 @@ namespace Kyoo.Postgresql.Migrations
b.Navigation("Studio");
});
modelBuilder.Entity("Kyoo.Abstractions.Models.Track", b =>
{
b.HasOne("Kyoo.Abstractions.Models.Episode", "Episode")
.WithMany("Tracks")
.HasForeignKey("EpisodeID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_tracks_episodes_episode_id");
b.Navigation("Episode");
});
modelBuilder.Entity("Kyoo.Abstractions.Models.WatchedEpisode", b =>
{
b.HasOne("Kyoo.Abstractions.Models.Episode", "Episode")
@ -1226,8 +1142,6 @@ namespace Kyoo.Postgresql.Migrations
modelBuilder.Entity("Kyoo.Abstractions.Models.Episode", b =>
{
b.Navigation("ExternalIDs");
b.Navigation("Tracks");
});
modelBuilder.Entity("Kyoo.Abstractions.Models.People", b =>