mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Make StartDate/EndDate nullable (#13494)
These dates are used as birthdate and death date for person (ask luke for why) and a non-nullable column would cause the null date become 1901-01-01, making all living people dead.
This commit is contained in:
parent
e7f32fb174
commit
2de04cb07c
@ -18,9 +18,9 @@ public class BaseItemEntity
|
||||
|
||||
public string? Path { get; set; }
|
||||
|
||||
public DateTime StartDate { get; set; }
|
||||
public DateTime? StartDate { get; set; }
|
||||
|
||||
public DateTime EndDate { get; set; }
|
||||
public DateTime? EndDate { get; set; }
|
||||
|
||||
public string? ChannelId { get; set; }
|
||||
|
||||
|
@ -645,7 +645,7 @@ public sealed class BaseItemRepository
|
||||
// dto.MediaType = Enum.TryParse<MediaType>(entity.MediaType);
|
||||
if (dto is IHasStartDate hasStartDate)
|
||||
{
|
||||
hasStartDate.StartDate = entity.StartDate;
|
||||
hasStartDate.StartDate = entity.StartDate.GetValueOrDefault();
|
||||
}
|
||||
|
||||
// Fields that are present in the DB but are never actually used
|
||||
@ -683,7 +683,7 @@ public sealed class BaseItemRepository
|
||||
|
||||
entity.ParentId = !dto.ParentId.IsEmpty() ? dto.ParentId : null;
|
||||
entity.Path = GetPathToSave(dto.Path);
|
||||
entity.EndDate = dto.EndDate.GetValueOrDefault();
|
||||
entity.EndDate = dto.EndDate;
|
||||
entity.CommunityRating = dto.CommunityRating;
|
||||
entity.CustomRating = dto.CustomRating;
|
||||
entity.IndexNumber = dto.IndexNumber;
|
||||
|
1595
Jellyfin.Server.Implementations/Migrations/20250204092455_MakeStartEndDateNullable.Designer.cs
generated
Normal file
1595
Jellyfin.Server.Implementations/Migrations/20250204092455_MakeStartEndDateNullable.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Jellyfin.Server.Implementations.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class MakeStartEndDateNullable : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<DateTime>(
|
||||
name: "StartDate",
|
||||
table: "BaseItems",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(DateTime),
|
||||
oldType: "TEXT");
|
||||
|
||||
migrationBuilder.AlterColumn<DateTime>(
|
||||
name: "EndDate",
|
||||
table: "BaseItems",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(DateTime),
|
||||
oldType: "TEXT");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<DateTime>(
|
||||
name: "StartDate",
|
||||
table: "BaseItems",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||
oldClrType: typeof(DateTime),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<DateTime>(
|
||||
name: "EndDate",
|
||||
table: "BaseItems",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||
oldClrType: typeof(DateTime),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true);
|
||||
}
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ namespace Jellyfin.Server.Implementations.Migrations
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "8.0.10");
|
||||
modelBuilder.HasAnnotation("ProductVersion", "9.0.1");
|
||||
|
||||
modelBuilder.Entity("Jellyfin.Data.Entities.AccessSchedule", b =>
|
||||
{
|
||||
@ -185,7 +185,7 @@ namespace Jellyfin.Server.Implementations.Migrations
|
||||
b.Property<DateTime?>("DateModified")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("EndDate")
|
||||
b.Property<DateTime?>("EndDate")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("EpisodeTitle")
|
||||
@ -323,7 +323,7 @@ namespace Jellyfin.Server.Implementations.Migrations
|
||||
b.Property<string>("SortName")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("StartDate")
|
||||
b.Property<DateTime?>("StartDate")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Studios")
|
||||
|
Loading…
x
Reference in New Issue
Block a user