mirror of
https://github.com/zoriya/Kyoo.git
synced 2026-05-31 03:15:16 -04:00
Add news view in the db
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,60 @@
|
||||
// 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;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Kyoo.Postgresql.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class News : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterDatabase()
|
||||
.Annotation("Npgsql:Enum:news_kind", "episode,movie");
|
||||
|
||||
// language=PostgreSQL
|
||||
migrationBuilder.Sql(@"
|
||||
CREATE VIEW news AS
|
||||
SELECT
|
||||
e.id, e.slug, e.name, NULL AS tagline, '{}' AS aliases, e.path, e.overview, '{}' AS tags, '{}' AS genres,
|
||||
NULL AS status, e.release_date AS air_date, e.poster_source, e.poster_blurhash, e.thumbnail_source, e.thumbnail_blurhash,
|
||||
e.logo_source,e.logo_blurhash, NULL AS trailer, e.external_id, e.season_number, e.episode_number, e.absolute_number,
|
||||
'episode'::news_kind AS kind, e.added_date
|
||||
FROM episodes AS e
|
||||
UNION ALL
|
||||
SELECT
|
||||
-m.id, m.slug, m.name, m.tagline, m.aliases, m.path, m.overview, m.tags, m.genres,
|
||||
m.status, m.air_date, m.poster_source, m.poster_blurhash, m.thumbnail_source, m.thumbnail_blurhash,
|
||||
m.logo_source, m.logo_blurhash, m.trailer, m.external_id, NULL AS season_number, NULL AS episode_number, NULL as absolute_number,
|
||||
'movie'::news_kind AS kind, m.added_date
|
||||
FROM movies AS m
|
||||
");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
// language=PostgreSQL
|
||||
migrationBuilder.Sql(@"DROP VIEW news");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,11 +19,12 @@ namespace Kyoo.Postgresql.Migrations
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.9")
|
||||
.HasAnnotation("ProductVersion", "7.0.12")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
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, "item_kind", new[] { "show", "movie", "collection" });
|
||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "news_kind", new[] { "episode", "movie" });
|
||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "status", new[] { "unknown", "finished", "airing", "planned" });
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
@@ -328,6 +329,98 @@ namespace Kyoo.Postgresql.Migrations
|
||||
b.ToTable("movies", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kyoo.Abstractions.Models.News", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int?>("AbsoluteNumber")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("absolute_number");
|
||||
|
||||
b.Property<DateTime>("AddedDate")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("added_date")
|
||||
.HasDefaultValueSql("now() at time zone 'utc'");
|
||||
|
||||
b.Property<DateTime?>("AirDate")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("air_date");
|
||||
|
||||
b.Property<string[]>("Aliases")
|
||||
.IsRequired()
|
||||
.HasColumnType("text[]")
|
||||
.HasColumnName("aliases");
|
||||
|
||||
b.Property<int?>("EpisodeNumber")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("episode_number");
|
||||
|
||||
b.Property<string>("ExternalId")
|
||||
.IsRequired()
|
||||
.HasColumnType("json")
|
||||
.HasColumnName("external_id");
|
||||
|
||||
b.Property<Genre[]>("Genres")
|
||||
.IsRequired()
|
||||
.HasColumnType("genre[]")
|
||||
.HasColumnName("genres");
|
||||
|
||||
b.Property<NewsKind>("Kind")
|
||||
.HasColumnType("news_kind")
|
||||
.HasColumnName("kind");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("name");
|
||||
|
||||
b.Property<string>("Overview")
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("overview");
|
||||
|
||||
b.Property<string>("Path")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("path");
|
||||
|
||||
b.Property<int?>("SeasonNumber")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("season_number");
|
||||
|
||||
b.Property<string>("Slug")
|
||||
.IsRequired()
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)")
|
||||
.HasColumnName("slug");
|
||||
|
||||
b.Property<Status?>("Status")
|
||||
.HasColumnType("status")
|
||||
.HasColumnName("status");
|
||||
|
||||
b.Property<string>("Tagline")
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("tagline");
|
||||
|
||||
b.Property<string[]>("Tags")
|
||||
.IsRequired()
|
||||
.HasColumnType("text[]")
|
||||
.HasColumnName("tags");
|
||||
|
||||
b.Property<string>("Trailer")
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("trailer");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk_news");
|
||||
|
||||
b.ToTable("news", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kyoo.Abstractions.Models.People", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@@ -1099,6 +1192,93 @@ namespace Kyoo.Postgresql.Migrations
|
||||
b.Navigation("Thumbnail");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kyoo.Abstractions.Models.News", b =>
|
||||
{
|
||||
b.OwnsOne("Kyoo.Abstractions.Models.Image", "Logo", b1 =>
|
||||
{
|
||||
b1.Property<int>("NewsId")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id");
|
||||
|
||||
b1.Property<string>("Blurhash")
|
||||
.IsRequired()
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("character varying(32)")
|
||||
.HasColumnName("logo_blurhash");
|
||||
|
||||
b1.Property<string>("Source")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("logo_source");
|
||||
|
||||
b1.HasKey("NewsId");
|
||||
|
||||
b1.ToTable("news");
|
||||
|
||||
b1.WithOwner()
|
||||
.HasForeignKey("NewsId")
|
||||
.HasConstraintName("fk_news_news_id");
|
||||
});
|
||||
|
||||
b.OwnsOne("Kyoo.Abstractions.Models.Image", "Poster", b1 =>
|
||||
{
|
||||
b1.Property<int>("NewsId")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id");
|
||||
|
||||
b1.Property<string>("Blurhash")
|
||||
.IsRequired()
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("character varying(32)")
|
||||
.HasColumnName("poster_blurhash");
|
||||
|
||||
b1.Property<string>("Source")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("poster_source");
|
||||
|
||||
b1.HasKey("NewsId");
|
||||
|
||||
b1.ToTable("news");
|
||||
|
||||
b1.WithOwner()
|
||||
.HasForeignKey("NewsId")
|
||||
.HasConstraintName("fk_news_news_id");
|
||||
});
|
||||
|
||||
b.OwnsOne("Kyoo.Abstractions.Models.Image", "Thumbnail", b1 =>
|
||||
{
|
||||
b1.Property<int>("NewsId")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id");
|
||||
|
||||
b1.Property<string>("Blurhash")
|
||||
.IsRequired()
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("character varying(32)")
|
||||
.HasColumnName("thumbnail_blurhash");
|
||||
|
||||
b1.Property<string>("Source")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("thumbnail_source");
|
||||
|
||||
b1.HasKey("NewsId");
|
||||
|
||||
b1.ToTable("news");
|
||||
|
||||
b1.WithOwner()
|
||||
.HasForeignKey("NewsId")
|
||||
.HasConstraintName("fk_news_news_id");
|
||||
});
|
||||
|
||||
b.Navigation("Logo");
|
||||
|
||||
b.Navigation("Poster");
|
||||
|
||||
b.Navigation("Thumbnail");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kyoo.Abstractions.Models.People", b =>
|
||||
{
|
||||
b.OwnsOne("Kyoo.Abstractions.Models.Image", "Logo", b1 =>
|
||||
|
||||
Reference in New Issue
Block a user