Browse Source

code cleanup

pull/31/head
Jason Dove 6 years ago
parent
commit
28094551e4
  1. 8
      ErsatzTV.Core/Domain/MediaItem/MediaItem.cs
  2. 2
      ErsatzTV.Core/Domain/Metadata/EpisodeMetadata.cs
  3. 2
      ErsatzTV.Core/Domain/Metadata/Metadata.cs
  4. 2
      ErsatzTV.Core/Domain/Metadata/MovieMetadata.cs
  5. 2
      ErsatzTV.Core/Domain/Metadata/ShowMetadata.cs
  6. 3
      ErsatzTV.Core/Domain/PlayoutProgramScheduleAnchor.cs
  7. 4
      ErsatzTV.Core/Domain/ProgramScheduleItem.cs
  8. 2
      ErsatzTV.Core/Domain/TelevisionShowMetadata.cs
  9. 19
      ErsatzTV.Core/Metadata/LocalMetadataProvider.cs
  10. 2
      ErsatzTV.Infrastructure/Data/Configurations/MediaItem/ShowConfiguration.cs
  11. 2
      ErsatzTV.Infrastructure/Data/Configurations/PlayoutProgramScheduleAnchorConfiguration.cs
  12. 10
      ErsatzTV.Infrastructure/Data/Repositories/MovieRepository.cs
  13. 51
      ErsatzTV.Infrastructure/Migrations/20210226025109_TelevisionMediaItems.cs
  14. 236
      ErsatzTV.Infrastructure/Migrations/20210226114450_Add_VersionsAndMetadata.cs
  15. 2
      ErsatzTV.Infrastructure/Migrations/20210226132335_Update_MovieMetadata.cs
  16. 450
      ErsatzTV.Infrastructure/Migrations/TvContextModelSnapshot.cs

8
ErsatzTV.Core/Domain/MediaItem/MediaItem.cs

@ -12,10 +12,7 @@ namespace ErsatzTV.Core.Domain @@ -12,10 +12,7 @@ namespace ErsatzTV.Core.Domain
public int LibraryPathId { get; set; }
public LibraryPath LibraryPath { get; set; }
public string Path { get; set; }
public string Poster { get; set; }
public DateTime? PosterLastWriteTime { get; set; }
// temporary fields to help migrations...
public int TelevisionShowId { get; set; }
public int TelevisionSeasonId { get; set; }
@ -23,5 +20,8 @@ namespace ErsatzTV.Core.Domain @@ -23,5 +20,8 @@ namespace ErsatzTV.Core.Domain
public List<Collection> Collections { get; set; }
public List<CollectionItem> CollectionItems { get; set; }
public string Path { get; set; }
public string Poster { get; set; }
public DateTime? PosterLastWriteTime { get; set; }
}
}

2
ErsatzTV.Core/Domain/Metadata/EpisodeMetadata.cs

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
{
public string Outline { get; set; }
public string Plot { get; set; }
public string Tagline { get; set; }
public string Tagline { get; set; }
public int EpisodeId { get; set; }
public Episode Episode { get; set; }
}

2
ErsatzTV.Core/Domain/Metadata/Metadata.cs

@ -11,6 +11,6 @@ namespace ErsatzTV.Core.Domain @@ -11,6 +11,6 @@ namespace ErsatzTV.Core.Domain
public string SortTitle { get; set; }
public DateTime? ReleaseDate { get; set; }
public DateTime DateAdded { get; set; }
public DateTime DateUpdated { get; set; }
public DateTime DateUpdated { get; set; }
}
}

2
ErsatzTV.Core/Domain/Metadata/MovieMetadata.cs

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
{
public string Outline { get; set; }
public string Plot { get; set; }
public string Tagline { get; set; }
public string Tagline { get; set; }
public int MovieId { get; set; }
public Movie Movie { get; set; }
}

2
ErsatzTV.Core/Domain/Metadata/ShowMetadata.cs

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
{
public string Outline { get; set; }
public string Plot { get; set; }
public string Tagline { get; set; }
public string Tagline { get; set; }
public int ShowId { get; set; }
public Show Show { get; set; }
}

3
ErsatzTV.Core/Domain/PlayoutProgramScheduleAnchor.cs

@ -7,9 +7,12 @@ @@ -7,9 +7,12 @@
public Playout Playout { get; set; }
public int ProgramScheduleId { get; set; }
public ProgramSchedule ProgramSchedule { get; set; }
public ProgramScheduleItemCollectionType CollectionType { get; set; }
// TODO: remove this
public int CollectionId { get; set; }
// TODO: rename this
public int? NewCollectionId { get; set; }
public Collection Collection { get; set; }

4
ErsatzTV.Core/Domain/ProgramScheduleItem.cs

@ -8,7 +8,9 @@ namespace ErsatzTV.Core.Domain @@ -8,7 +8,9 @@ namespace ErsatzTV.Core.Domain
public int Index { get; set; }
public StartType StartType => StartTime.HasValue ? StartType.Fixed : StartType.Dynamic;
public TimeSpan? StartTime { get; set; }
public ProgramScheduleItemCollectionType CollectionType { get; set; }
// TODO: remove these
public int? MediaCollectionId { get; set; }
public MediaCollection MediaCollection { get; set; }
@ -18,7 +20,7 @@ namespace ErsatzTV.Core.Domain @@ -18,7 +20,7 @@ namespace ErsatzTV.Core.Domain
public TelevisionSeason TelevisionSeason { get; set; }
public int ProgramScheduleId { get; set; }
public ProgramSchedule ProgramSchedule { get; set; }
public int? CollectionId { get; set; }
public Collection Collection { get; set; }
public int? MediaItemId { get; set; }

2
ErsatzTV.Core/Domain/TelevisionShowMetadata.cs

@ -6,7 +6,9 @@ namespace ErsatzTV.Core.Domain @@ -6,7 +6,9 @@ namespace ErsatzTV.Core.Domain
{
public int Id { get; set; }
public int TelevisionShowId { get; set; }
public TelevisionShow TelevisionShow { get; set; }
// public int ShowId { get; set; }
// public Show Show { get; set; }
public MetadataSource Source { get; set; }

19
ErsatzTV.Core/Metadata/LocalMetadataProvider.cs

@ -97,7 +97,22 @@ namespace ErsatzTV.Core.Metadata @@ -97,7 +97,22 @@ namespace ErsatzTV.Core.Metadata
private async Task ApplyMetadataUpdate(Movie movie, MovieMetadata metadata)
{
movie.MovieMetadata = new List<MovieMetadata> { metadata };
movie.MovieMetadata.HeadOrNone().Match(
existing =>
{
existing.Outline = metadata.Outline;
existing.Plot = metadata.Plot;
existing.Tagline = metadata.Tagline;
existing.Title = metadata.Title;
existing.DateAdded = metadata.DateAdded;
existing.DateUpdated = metadata.DateUpdated;
existing.MetadataKind = metadata.MetadataKind;
existing.OriginalTitle = metadata.OriginalTitle;
existing.ReleaseDate = metadata.ReleaseDate;
existing.SortTitle = metadata.SortTitle;
},
() => movie.MovieMetadata = new List<MovieMetadata> { metadata });
await _mediaItemRepository.Update(movie);
}
@ -230,7 +245,7 @@ namespace ErsatzTV.Core.Metadata @@ -230,7 +245,7 @@ namespace ErsatzTV.Core.Metadata
ReleaseDate = nfo.Premiered,
Plot = nfo.Plot,
Outline = nfo.Outline,
Tagline = nfo.Tagline,
Tagline = nfo.Tagline
},
None);
}

2
ErsatzTV.Infrastructure/Data/Configurations/MediaItem/ShowConfiguration.cs

@ -14,7 +14,7 @@ namespace ErsatzTV.Infrastructure.Data.Configurations @@ -14,7 +14,7 @@ namespace ErsatzTV.Infrastructure.Data.Configurations
.WithOne(s => s.Show)
.HasForeignKey(s => s.ShowId)
.OnDelete(DeleteBehavior.Cascade);
builder.HasMany(s => s.ShowMetadata)
.WithOne(s => s.Show)
.HasForeignKey(s => s.ShowId)

2
ErsatzTV.Infrastructure/Data/Configurations/PlayoutProgramScheduleAnchorConfiguration.cs

@ -12,7 +12,7 @@ namespace ErsatzTV.Infrastructure.Data.Configurations @@ -12,7 +12,7 @@ namespace ErsatzTV.Infrastructure.Data.Configurations
builder.OwnsOne(a => a.EnumeratorState)
.WithOwner();
// TODO: fix this foreign key
builder.HasOne(i => i.Collection)
.WithMany()

10
ErsatzTV.Infrastructure/Data/Repositories/MovieRepository.cs

@ -1,7 +1,6 @@ @@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using Dapper;
using ErsatzTV.Core;
@ -15,8 +14,8 @@ namespace ErsatzTV.Infrastructure.Data.Repositories @@ -15,8 +14,8 @@ namespace ErsatzTV.Infrastructure.Data.Repositories
{
public class MovieRepository : IMovieRepository
{
private readonly TvContext _dbContext;
private readonly IDbConnection _dbConnection;
private readonly TvContext _dbContext;
public MovieRepository(TvContext dbContext, IDbConnection dbConnection)
{
@ -67,10 +66,13 @@ namespace ErsatzTV.Infrastructure.Data.Repositories @@ -67,10 +66,13 @@ namespace ErsatzTV.Infrastructure.Data.Repositories
_dbConnection.QuerySingleAsync<int>(@"SELECT COUNT(DISTINCT MovieId) FROM NewMovieMetadata");
public Task<List<MovieMetadata>> GetPagedMovies(int pageNumber, int pageSize) =>
_dbContext.MovieMetadata.FromSqlRaw(@"SELECT * FROM NewMovieMetadata WHERE Id IN
_dbContext.MovieMetadata.FromSqlRaw(
@"SELECT * FROM NewMovieMetadata WHERE Id IN
(SELECT Id FROM NewMovieMetadata GROUP BY MovieId, MetadataKind HAVING MetadataKind = MAX(MetadataKind))
ORDER BY SortTitle
LIMIT {0} OFFSET {1}", pageSize, (pageNumber - 1) * pageSize)
LIMIT {0} OFFSET {1}",
pageSize,
(pageNumber - 1) * pageSize)
.ToListAsync();
private async Task<Either<BaseError, Movie>> AddMovie(int libraryPathId, string path)

51
ErsatzTV.Infrastructure/Migrations/20210226025109_TelevisionMediaItems.cs

@ -143,71 +143,80 @@ namespace ErsatzTV.Infrastructure.Migrations @@ -143,71 +143,80 @@ namespace ErsatzTV.Infrastructure.Migrations
"IX_Season_ShowId",
"Season",
"ShowId");
// create show media items
migrationBuilder.Sql(@"INSERT INTO MediaItem (TelevisionShowId, LibraryPathId)
migrationBuilder.Sql(
@"INSERT INTO MediaItem (TelevisionShowId, LibraryPathId)
SELECT distinct ts.Id, mi.LibraryPathId
FROM TelevisionShow ts
INNER JOIN TelevisionSeason tsn ON tsn.TelevisionShowId = ts.Id
INNER JOIN TelevisionEpisode te ON te.SeasonId = tsn.Id
INNER JOIN MediaItem mi on mi.Id = te.Id");
// create shows
migrationBuilder.Sql(@"INSERT INTO Show (Id) SELECT Id FROM MediaItem WHERE TelevisionShowId > 0");
// create season media items
migrationBuilder.Sql(@"INSERT INTO MediaItem (TelevisionSeasonId, LibraryPathId)
migrationBuilder.Sql(
@"INSERT INTO MediaItem (TelevisionSeasonId, LibraryPathId)
SELECT distinct tsn.Id, mi.LibraryPathId
FROM TelevisionSeason tsn
INNER JOIN TelevisionEpisode te ON te.SeasonId = tsn.Id
INNER JOIN MediaItem mi on mi.Id = te.Id");
// create seasons
migrationBuilder.Sql(@"INSERT INTO Season (Id, ShowId)
migrationBuilder.Sql(
@"INSERT INTO Season (Id, ShowId)
SELECT mi.Id, mi2.Id
FROM MediaItem mi
INNER JOIN TelevisionSeason tsn ON tsn.Id = mi.TelevisionSeasonId
INNER JOIN MediaItem mi2 ON mi2.TelevisionShowId = tsn.TelevisionShowId AND mi.LibraryPathId = mi2.LibraryPathId");
INNER JOIN MediaItem mi2 ON mi2.TelevisionShowId = tsn.TelevisionShowId AND mi.LibraryPathId = mi2.LibraryPathId");
// mark episode media items
migrationBuilder.Sql(@"UPDATE MediaItem SET TelevisionEpisodeId = Id
migrationBuilder.Sql(
@"UPDATE MediaItem SET TelevisionEpisodeId = Id
WHERE Id IN (SELECT Id FROM TelevisionEpisode)");
// create episodes
migrationBuilder.Sql(@"INSERT INTO Episode (Id, SeasonId)
migrationBuilder.Sql(
@"INSERT INTO Episode (Id, SeasonId)
SELECT mi.Id, mi2.Id
FROM MediaItem mi
INNER JOIN TelevisionEpisode te on mi.Id = te.Id
INNER JOIN MediaItem mi2 ON mi2.TelevisionSeasonId = te.SeasonId AND mi.LibraryPathId = mi2.LibraryPathId");
// collections
migrationBuilder.Sql(@"INSERT INTO Collection (Name) SELECT Name FROM MediaCollection");
// collection movies
migrationBuilder.Sql(@"INSERT INTO CollectionItem (CollectionId, MediaItemId)
migrationBuilder.Sql(
@"INSERT INTO CollectionItem (CollectionId, MediaItemId)
SELECT c.Id, smcm.MoviesId
FROM Collection c
INNER JOIN MediaCollection mc on mc.Name = c.Name
INNER JOIN SimpleMediaCollectionMovie smcm ON smcm.SimpleMediaCollectionsId = mc.Id");
// collection shows
migrationBuilder.Sql(@"INSERT INTO CollectionItem (CollectionId, MediaItemId)
migrationBuilder.Sql(
@"INSERT INTO CollectionItem (CollectionId, MediaItemId)
SELECT c.Id, mi.Id
FROM Collection c
INNER JOIN MediaCollection mc on mc.Name = c.Name
INNER JOIN SimpleMediaCollectionShow smcs ON smcs.SimpleMediaCollectionsId = mc.Id
INNER JOIN MediaItem mi ON mi.TelevisionShowId = smcs.TelevisionShowsId");
// collection seasons
migrationBuilder.Sql(@"INSERT INTO CollectionItem (CollectionId, MediaItemId)
migrationBuilder.Sql(
@"INSERT INTO CollectionItem (CollectionId, MediaItemId)
SELECT c.Id, mi.Id
FROM Collection c
INNER JOIN MediaCollection mc on mc.Name = c.Name
INNER JOIN SimpleMediaCollectionSeason smcs ON smcs.SimpleMediaCollectionsId = mc.Id
INNER JOIN MediaItem mi ON mi.TelevisionSeasonId = smcs.TelevisionSeasonsId");
// collection episodes
migrationBuilder.Sql(@"INSERT INTO CollectionItem (CollectionId, MediaItemId)
migrationBuilder.Sql(
@"INSERT INTO CollectionItem (CollectionId, MediaItemId)
SELECT c.Id, mi.Id
FROM Collection c
INNER JOIN MediaCollection mc on mc.Name = c.Name

236
ErsatzTV.Infrastructure/Migrations/20210226114450_Add_VersionsAndMetadata.cs

@ -8,216 +8,216 @@ namespace ErsatzTV.Infrastructure.Migrations @@ -8,216 +8,216 @@ namespace ErsatzTV.Infrastructure.Migrations
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "SeasonNumber",
table: "Season",
type: "INTEGER",
"SeasonNumber",
"Season",
"INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "EpisodeNumber",
table: "Episode",
type: "INTEGER",
"EpisodeNumber",
"Episode",
"INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "EpisodeMetadata",
columns: table => new
"EpisodeMetadata",
table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
Id = table.Column<int>("INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Outline = table.Column<string>(type: "TEXT", nullable: true),
Plot = table.Column<string>(type: "TEXT", nullable: true),
Tagline = table.Column<string>(type: "TEXT", nullable: true),
EpisodeId = table.Column<int>(type: "INTEGER", nullable: false),
MetadataKind = table.Column<int>(type: "INTEGER", nullable: false),
Title = table.Column<string>(type: "TEXT", nullable: true),
OriginalTitle = table.Column<string>(type: "TEXT", nullable: true),
SortTitle = table.Column<string>(type: "TEXT", nullable: true),
ReleaseDate = table.Column<DateTimeOffset>(type: "TEXT", nullable: true),
DateAdded = table.Column<DateTimeOffset>(type: "TEXT", nullable: false),
DateUpdated = table.Column<DateTimeOffset>(type: "TEXT", nullable: false)
Outline = table.Column<string>("TEXT", nullable: true),
Plot = table.Column<string>("TEXT", nullable: true),
Tagline = table.Column<string>("TEXT", nullable: true),
EpisodeId = table.Column<int>("INTEGER", nullable: false),
MetadataKind = table.Column<int>("INTEGER", nullable: false),
Title = table.Column<string>("TEXT", nullable: true),
OriginalTitle = table.Column<string>("TEXT", nullable: true),
SortTitle = table.Column<string>("TEXT", nullable: true),
ReleaseDate = table.Column<DateTimeOffset>("TEXT", nullable: true),
DateAdded = table.Column<DateTimeOffset>("TEXT", nullable: false),
DateUpdated = table.Column<DateTimeOffset>("TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_EpisodeMetadata", x => x.Id);
table.ForeignKey(
name: "FK_EpisodeMetadata_Episode_EpisodeId",
column: x => x.EpisodeId,
principalTable: "Episode",
principalColumn: "Id",
"FK_EpisodeMetadata_Episode_EpisodeId",
x => x.EpisodeId,
"Episode",
"Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "MediaVersion",
columns: table => new
"MediaVersion",
table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
Id = table.Column<int>("INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: true),
Duration = table.Column<TimeSpan>(type: "TEXT", nullable: false),
SampleAspectRatio = table.Column<string>(type: "TEXT", nullable: true),
DisplayAspectRatio = table.Column<string>(type: "TEXT", nullable: true),
VideoCodec = table.Column<string>(type: "TEXT", nullable: true),
AudioCodec = table.Column<string>(type: "TEXT", nullable: true),
IsInterlaced = table.Column<bool>(type: "INTEGER", nullable: false),
Width = table.Column<int>(type: "INTEGER", nullable: false),
Height = table.Column<int>(type: "INTEGER", nullable: false),
EpisodeId = table.Column<int>(type: "INTEGER", nullable: true),
MovieId = table.Column<int>(type: "INTEGER", nullable: true)
Name = table.Column<string>("TEXT", nullable: true),
Duration = table.Column<TimeSpan>("TEXT", nullable: false),
SampleAspectRatio = table.Column<string>("TEXT", nullable: true),
DisplayAspectRatio = table.Column<string>("TEXT", nullable: true),
VideoCodec = table.Column<string>("TEXT", nullable: true),
AudioCodec = table.Column<string>("TEXT", nullable: true),
IsInterlaced = table.Column<bool>("INTEGER", nullable: false),
Width = table.Column<int>("INTEGER", nullable: false),
Height = table.Column<int>("INTEGER", nullable: false),
EpisodeId = table.Column<int>("INTEGER", nullable: true),
MovieId = table.Column<int>("INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_MediaVersion", x => x.Id);
table.ForeignKey(
name: "FK_MediaVersion_Episode_EpisodeId",
column: x => x.EpisodeId,
principalTable: "Episode",
principalColumn: "Id",
"FK_MediaVersion_Episode_EpisodeId",
x => x.EpisodeId,
"Episode",
"Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_MediaVersion_Movie_MovieId",
column: x => x.MovieId,
principalTable: "Movie",
principalColumn: "Id",
"FK_MediaVersion_Movie_MovieId",
x => x.MovieId,
"Movie",
"Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "NewMovieMetadata",
columns: table => new
"NewMovieMetadata",
table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
Id = table.Column<int>("INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Outline = table.Column<string>(type: "TEXT", nullable: true),
Plot = table.Column<string>(type: "TEXT", nullable: true),
Tagline = table.Column<string>(type: "TEXT", nullable: true),
MovieId = table.Column<int>(type: "INTEGER", nullable: false),
MetadataKind = table.Column<int>(type: "INTEGER", nullable: false),
Title = table.Column<string>(type: "TEXT", nullable: true),
OriginalTitle = table.Column<string>(type: "TEXT", nullable: true),
SortTitle = table.Column<string>(type: "TEXT", nullable: true),
ReleaseDate = table.Column<DateTimeOffset>(type: "TEXT", nullable: true),
DateAdded = table.Column<DateTimeOffset>(type: "TEXT", nullable: false),
DateUpdated = table.Column<DateTimeOffset>(type: "TEXT", nullable: false)
Outline = table.Column<string>("TEXT", nullable: true),
Plot = table.Column<string>("TEXT", nullable: true),
Tagline = table.Column<string>("TEXT", nullable: true),
MovieId = table.Column<int>("INTEGER", nullable: false),
MetadataKind = table.Column<int>("INTEGER", nullable: false),
Title = table.Column<string>("TEXT", nullable: true),
OriginalTitle = table.Column<string>("TEXT", nullable: true),
SortTitle = table.Column<string>("TEXT", nullable: true),
ReleaseDate = table.Column<DateTimeOffset>("TEXT", nullable: true),
DateAdded = table.Column<DateTimeOffset>("TEXT", nullable: false),
DateUpdated = table.Column<DateTimeOffset>("TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_NewMovieMetadata", x => x.Id);
table.ForeignKey(
name: "FK_NewMovieMetadata_Movie_MovieId",
column: x => x.MovieId,
principalTable: "Movie",
principalColumn: "Id",
"FK_NewMovieMetadata_Movie_MovieId",
x => x.MovieId,
"Movie",
"Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ShowMetadata",
columns: table => new
"ShowMetadata",
table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
Id = table.Column<int>("INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Outline = table.Column<string>(type: "TEXT", nullable: true),
Plot = table.Column<string>(type: "TEXT", nullable: true),
Tagline = table.Column<string>(type: "TEXT", nullable: true),
ShowId = table.Column<int>(type: "INTEGER", nullable: false),
MetadataKind = table.Column<int>(type: "INTEGER", nullable: false),
Title = table.Column<string>(type: "TEXT", nullable: true),
OriginalTitle = table.Column<string>(type: "TEXT", nullable: true),
SortTitle = table.Column<string>(type: "TEXT", nullable: true),
ReleaseDate = table.Column<DateTimeOffset>(type: "TEXT", nullable: true),
DateAdded = table.Column<DateTimeOffset>(type: "TEXT", nullable: false),
DateUpdated = table.Column<DateTimeOffset>(type: "TEXT", nullable: false)
Outline = table.Column<string>("TEXT", nullable: true),
Plot = table.Column<string>("TEXT", nullable: true),
Tagline = table.Column<string>("TEXT", nullable: true),
ShowId = table.Column<int>("INTEGER", nullable: false),
MetadataKind = table.Column<int>("INTEGER", nullable: false),
Title = table.Column<string>("TEXT", nullable: true),
OriginalTitle = table.Column<string>("TEXT", nullable: true),
SortTitle = table.Column<string>("TEXT", nullable: true),
ReleaseDate = table.Column<DateTimeOffset>("TEXT", nullable: true),
DateAdded = table.Column<DateTimeOffset>("TEXT", nullable: false),
DateUpdated = table.Column<DateTimeOffset>("TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ShowMetadata", x => x.Id);
table.ForeignKey(
name: "FK_ShowMetadata_Show_ShowId",
column: x => x.ShowId,
principalTable: "Show",
principalColumn: "Id",
"FK_ShowMetadata_Show_ShowId",
x => x.ShowId,
"Show",
"Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "MediaFile",
columns: table => new
"MediaFile",
table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
Id = table.Column<int>("INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Path = table.Column<string>(type: "TEXT", nullable: true),
MediaVersionId = table.Column<int>(type: "INTEGER", nullable: false)
Path = table.Column<string>("TEXT", nullable: true),
MediaVersionId = table.Column<int>("INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_MediaFile", x => x.Id);
table.ForeignKey(
name: "FK_MediaFile_MediaVersion_MediaVersionId",
column: x => x.MediaVersionId,
principalTable: "MediaVersion",
principalColumn: "Id",
"FK_MediaFile_MediaVersion_MediaVersionId",
x => x.MediaVersionId,
"MediaVersion",
"Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_EpisodeMetadata_EpisodeId",
table: "EpisodeMetadata",
column: "EpisodeId");
"IX_EpisodeMetadata_EpisodeId",
"EpisodeMetadata",
"EpisodeId");
migrationBuilder.CreateIndex(
name: "IX_MediaFile_MediaVersionId",
table: "MediaFile",
column: "MediaVersionId");
"IX_MediaFile_MediaVersionId",
"MediaFile",
"MediaVersionId");
migrationBuilder.CreateIndex(
name: "IX_MediaVersion_EpisodeId",
table: "MediaVersion",
column: "EpisodeId");
"IX_MediaVersion_EpisodeId",
"MediaVersion",
"EpisodeId");
migrationBuilder.CreateIndex(
name: "IX_MediaVersion_MovieId",
table: "MediaVersion",
column: "MovieId");
"IX_MediaVersion_MovieId",
"MediaVersion",
"MovieId");
migrationBuilder.CreateIndex(
name: "IX_NewMovieMetadata_MovieId",
table: "NewMovieMetadata",
column: "MovieId");
"IX_NewMovieMetadata_MovieId",
"NewMovieMetadata",
"MovieId");
migrationBuilder.CreateIndex(
name: "IX_ShowMetadata_ShowId",
table: "ShowMetadata",
column: "ShowId");
"IX_ShowMetadata_ShowId",
"ShowMetadata",
"ShowId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "EpisodeMetadata");
"EpisodeMetadata");
migrationBuilder.DropTable(
name: "MediaFile");
"MediaFile");
migrationBuilder.DropTable(
name: "NewMovieMetadata");
"NewMovieMetadata");
migrationBuilder.DropTable(
name: "ShowMetadata");
"ShowMetadata");
migrationBuilder.DropTable(
name: "MediaVersion");
"MediaVersion");
migrationBuilder.DropColumn(
name: "SeasonNumber",
table: "Season");
"SeasonNumber",
"Season");
migrationBuilder.DropColumn(
name: "EpisodeNumber",
table: "Episode");
"EpisodeNumber",
"Episode");
}
}
}

2
ErsatzTV.Infrastructure/Migrations/20210226132335_Update_MovieMetadata.cs

@ -8,7 +8,7 @@ namespace ErsatzTV.Infrastructure.Migrations @@ -8,7 +8,7 @@ namespace ErsatzTV.Infrastructure.Migrations
protected override void Up(MigrationBuilder migrationBuilder)
{
var now = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.FFFFFFF");
migrationBuilder.Sql(
@$"INSERT INTO NewMovieMetadata (Outline, Plot, Tagline, MovieId, MetadataKind, Title, OriginalTitle, SortTitle, ReleaseDate, DateAdded, DateUpdated)
SELECT mm.Outline, mm.Plot, mm.Tagline, m.Id, mm.Source, mm.Title, null, mm.SortTitle, mm.Premiered, '{now}', mm.LastWriteTime

450
ErsatzTV.Infrastructure/Migrations/TvContextModelSnapshot.cs

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save