Add next refresh date migration

This commit is contained in:
Zoe Roux 2024-04-14 23:37:08 +02:00
parent 5a9b846f7c
commit 7140d308fd
No known key found for this signature in database
3 changed files with 1461 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,83 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Kyoo.Postgresql.Migrations;
/// <inheritdoc />
public partial class AddNextRefresh : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "next_metadata_refresh",
table: "shows",
type: "timestamp with time zone",
nullable: true,
defaultValueSql: "now() at time zone 'utc' + interval '2 hours'"
);
migrationBuilder.AddColumn<DateTime>(
name: "next_metadata_refresh",
table: "seasons",
type: "timestamp with time zone",
nullable: true,
defaultValueSql: "now() at time zone 'utc' + interval '2 hours'"
);
migrationBuilder.AddColumn<DateTime>(
name: "next_metadata_refresh",
table: "movies",
type: "timestamp with time zone",
nullable: true,
defaultValueSql: "now() at time zone 'utc' + interval '2 hours'"
);
migrationBuilder.AddColumn<DateTime>(
name: "next_metadata_refresh",
table: "episodes",
type: "timestamp with time zone",
nullable: true,
defaultValueSql: "now() at time zone 'utc' + interval '2 hours'"
);
migrationBuilder.AddColumn<DateTime>(
name: "next_metadata_refresh",
table: "collections",
type: "timestamp with time zone",
nullable: true,
defaultValueSql: "now() at time zone 'utc' + interval '2 hours'"
);
// language=PostgreSQL
migrationBuilder.Sql(
"""
update episodes as e set external_id = jsonb_build_object(
'ShowId', e.show_id,
'SeasonNumber', e.season_number,
'EpisodeNumber', e.episode_number,
'Link', null
);
"""
);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(name: "next_metadata_refresh", table: "shows");
migrationBuilder.DropColumn(name: "next_metadata_refresh", table: "seasons");
migrationBuilder.DropColumn(name: "next_metadata_refresh", table: "movies");
migrationBuilder.DropColumn(name: "next_metadata_refresh", table: "episodes");
migrationBuilder.DropColumn(name: "next_metadata_refresh", table: "collections");
// language=PostgreSQL
migrationBuilder.Sql("update episodes as e set external_id = '{}';");
}
}

View File

@ -19,7 +19,7 @@ namespace Kyoo.Postgresql.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.3")
.HasAnnotation("ProductVersion", "8.0.4")
.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", "kids", "news", "reality", "soap", "talk", "politics" });
@ -50,6 +50,12 @@ namespace Kyoo.Postgresql.Migrations
.HasColumnType("text")
.HasColumnName("name");
b.Property<DateTime?>("NextMetadataRefresh")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasColumnName("next_metadata_refresh")
.HasDefaultValueSql("now() at time zone 'utc' + interval '2 hours'");
b.Property<string>("Overview")
.HasColumnType("text")
.HasColumnName("overview");
@ -100,6 +106,12 @@ namespace Kyoo.Postgresql.Migrations
.HasColumnType("text")
.HasColumnName("name");
b.Property<DateTime?>("NextMetadataRefresh")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasColumnName("next_metadata_refresh")
.HasDefaultValueSql("now() at time zone 'utc' + interval '2 hours'");
b.Property<string>("Overview")
.HasColumnType("text")
.HasColumnName("overview");
@ -262,6 +274,12 @@ namespace Kyoo.Postgresql.Migrations
.HasColumnType("text")
.HasColumnName("name");
b.Property<DateTime?>("NextMetadataRefresh")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasColumnName("next_metadata_refresh")
.HasDefaultValueSql("now() at time zone 'utc' + interval '2 hours'");
b.Property<string>("Overview")
.HasColumnType("text")
.HasColumnName("overview");
@ -386,6 +404,12 @@ namespace Kyoo.Postgresql.Migrations
.HasColumnType("text")
.HasColumnName("name");
b.Property<DateTime?>("NextMetadataRefresh")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasColumnName("next_metadata_refresh")
.HasDefaultValueSql("now() at time zone 'utc' + interval '2 hours'");
b.Property<string>("Overview")
.HasColumnType("text")
.HasColumnName("overview");
@ -459,6 +483,12 @@ namespace Kyoo.Postgresql.Migrations
.HasColumnType("text")
.HasColumnName("name");
b.Property<DateTime?>("NextMetadataRefresh")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasColumnName("next_metadata_refresh")
.HasDefaultValueSql("now() at time zone 'utc' + interval '2 hours'");
b.Property<string>("Overview")
.HasColumnType("text")
.HasColumnName("overview");