Fix database migration issue

This commit is contained in:
Zoe Roux 2023-07-22 16:34:47 +09:00
parent f9df0b8a12
commit b753fdd2b0
13 changed files with 42 additions and 33 deletions

View File

@ -57,6 +57,6 @@ namespace Kyoo.Abstractions.Models
[LoadableRelation] public ICollection<Library> Libraries { get; set; } [LoadableRelation] public ICollection<Library> Libraries { get; set; }
/// <inheritdoc /> /// <inheritdoc />
[EditableRelation] [LoadableRelation] public ICollection<MetadataID> ExternalIDs { get; set; } [EditableRelation][LoadableRelation] public ICollection<MetadataID> ExternalIDs { get; set; }
} }
} }

View File

@ -146,12 +146,12 @@ namespace Kyoo.Abstractions.Models
public DateTime? ReleaseDate { get; set; } public DateTime? ReleaseDate { get; set; }
/// <inheritdoc /> /// <inheritdoc />
[EditableRelation] [LoadableRelation] public ICollection<MetadataID> ExternalIDs { get; set; } [EditableRelation][LoadableRelation] public ICollection<MetadataID> ExternalIDs { get; set; }
/// <summary> /// <summary>
/// The list of tracks this episode has. This lists video, audio and subtitles available. /// The list of tracks this episode has. This lists video, audio and subtitles available.
/// </summary> /// </summary>
[EditableRelation] [LoadableRelation] public ICollection<Track> Tracks { get; set; } [EditableRelation][LoadableRelation] public ICollection<Track> Tracks { get; set; }
/// <summary> /// <summary>
/// Get the slug of an episode. /// Get the slug of an episode.

View File

@ -45,7 +45,7 @@ namespace Kyoo.Abstractions.Models
/// <summary> /// <summary>
/// The list of <see cref="Provider"/> used for items in this library. /// The list of <see cref="Provider"/> used for items in this library.
/// </summary> /// </summary>
[EditableRelation] [LoadableRelation] public ICollection<Provider> Providers { get; set; } [EditableRelation][LoadableRelation] public ICollection<Provider> Providers { get; set; }
/// <summary> /// <summary>
/// The list of shows in this library. /// The list of shows in this library.

View File

@ -41,11 +41,11 @@ namespace Kyoo.Abstractions.Models
public Dictionary<int, string> Images { get; set; } public Dictionary<int, string> Images { get; set; }
/// <inheritdoc /> /// <inheritdoc />
[EditableRelation] [LoadableRelation] public ICollection<MetadataID> ExternalIDs { get; set; } [EditableRelation][LoadableRelation] public ICollection<MetadataID> ExternalIDs { get; set; }
/// <summary> /// <summary>
/// The list of roles this person has played in. See <see cref="PeopleRole"/> for more information. /// The list of roles this person has played in. See <see cref="PeopleRole"/> for more information.
/// </summary> /// </summary>
[EditableRelation] [LoadableRelation] public ICollection<PeopleRole> Roles { get; set; } [EditableRelation][LoadableRelation] public ICollection<PeopleRole> Roles { get; set; }
} }
} }

View File

@ -102,7 +102,7 @@ namespace Kyoo.Abstractions.Models
public Dictionary<int, string> Images { get; set; } public Dictionary<int, string> Images { get; set; }
/// <inheritdoc /> /// <inheritdoc />
[EditableRelation] [LoadableRelation] public ICollection<MetadataID> ExternalIDs { get; set; } [EditableRelation][LoadableRelation] public ICollection<MetadataID> ExternalIDs { get; set; }
/// <summary> /// <summary>
/// The list of episodes that this season contains. /// The list of episodes that this season contains.

View File

@ -88,7 +88,7 @@ namespace Kyoo.Abstractions.Models
public bool IsMovie { get; set; } public bool IsMovie { get; set; }
/// <inheritdoc /> /// <inheritdoc />
[EditableRelation] [LoadableRelation] public ICollection<MetadataID> ExternalIDs { get; set; } [EditableRelation][LoadableRelation] public ICollection<MetadataID> ExternalIDs { get; set; }
/// <summary> /// <summary>
/// The ID of the Studio that made this show. /// The ID of the Studio that made this show.
@ -99,17 +99,17 @@ namespace Kyoo.Abstractions.Models
/// The Studio that made this show. /// The Studio that made this show.
/// This must be explicitly loaded via a call to <see cref="ILibraryManager.Load"/>. /// This must be explicitly loaded via a call to <see cref="ILibraryManager.Load"/>.
/// </summary> /// </summary>
[LoadableRelation(nameof(StudioID))] [EditableRelation] public Studio Studio { get; set; } [LoadableRelation(nameof(StudioID))][EditableRelation] public Studio Studio { get; set; }
/// <summary> /// <summary>
/// The list of genres (themes) this show has. /// The list of genres (themes) this show has.
/// </summary> /// </summary>
[LoadableRelation] [EditableRelation] public ICollection<Genre> Genres { get; set; } [LoadableRelation][EditableRelation] public ICollection<Genre> Genres { get; set; }
/// <summary> /// <summary>
/// The list of people that made this show. /// The list of people that made this show.
/// </summary> /// </summary>
[LoadableRelation] [EditableRelation] public ICollection<PeopleRole> People { get; set; } [LoadableRelation][EditableRelation] public ICollection<PeopleRole> People { get; set; }
/// <summary> /// <summary>
/// The different seasons in this show. If this is a movie, this list is always null or empty. /// The different seasons in this show. If this is a movie, this list is always null or empty.

View File

@ -44,7 +44,7 @@ namespace Kyoo.Abstractions.Models
[LoadableRelation] public ICollection<Show> Shows { get; set; } [LoadableRelation] public ICollection<Show> Shows { get; set; }
/// <inheritdoc /> /// <inheritdoc />
[EditableRelation] [LoadableRelation] public ICollection<MetadataID> ExternalIDs { get; set; } [EditableRelation][LoadableRelation] public ICollection<MetadataID> ExternalIDs { get; set; }
/// <summary> /// <summary>
/// Create a new, empty, <see cref="Studio"/>. /// Create a new, empty, <see cref="Studio"/>.

View File

@ -15,7 +15,8 @@ namespace Kyoo.Postgresql.Migrations
[Migration("20230621074246_RemoveTrigers")] [Migration("20230621074246_RemoveTrigers")]
partial class RemoveTrigers partial class RemoveTrigers
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) /// <inheritdoc/>
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder

View File

@ -1,19 +1,33 @@
// 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 Microsoft.EntityFrameworkCore.Migrations;
namespace Kyoo.Postgresql.Migrations namespace Kyoo.Postgresql.Migrations
{ {
/// <summary>
/// Remove triggers
/// </summary>
public partial class RemoveTrigers : Migration public partial class RemoveTrigers : Migration
{ {
/// <inheritdoc/>
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(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")
.OldAnnotation("Npgsql:Enum:stream_type", "unknown,video,audio,subtitle,attachment");
// language=PostgreSQL // language=PostgreSQL
migrationBuilder.Sql("DROP TRIGGER show_slug_trigger ON shows;"); migrationBuilder.Sql("DROP TRIGGER show_slug_trigger ON shows;");
// language=PostgreSQL // language=PostgreSQL
@ -36,15 +50,9 @@ namespace Kyoo.Postgresql.Migrations
migrationBuilder.Sql(@"DROP FUNCTION episode_update_tracks_slug;"); migrationBuilder.Sql(@"DROP FUNCTION episode_update_tracks_slug;");
} }
/// <inheritdoc/>
protected override void Down(MigrationBuilder migrationBuilder) 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,attachment")
.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");
} }
} }
} }

View File

@ -45,11 +45,11 @@ namespace Kyoo.Tests.Database
PeopleRepository people = new(_NewContext(), provider, PeopleRepository people = new(_NewContext(), provider,
new Lazy<IShowRepository>(() => LibraryManager.ShowRepository)); new Lazy<IShowRepository>(() => LibraryManager.ShowRepository));
ShowRepository show = new(_NewContext(), studio, people, genre, provider); ShowRepository show = new(_NewContext(), studio, people, genre, provider);
SeasonRepository season = new(_NewContext(), provider); SeasonRepository season = new(_NewContext(), show, provider);
LibraryItemRepository libraryItem = new(_NewContext(), LibraryItemRepository libraryItem = new(_NewContext(),
new Lazy<ILibraryRepository>(() => LibraryManager.LibraryRepository)); new Lazy<ILibraryRepository>(() => LibraryManager.LibraryRepository));
TrackRepository track = new(_NewContext()); TrackRepository track = new(_NewContext());
EpisodeRepository episode = new(_NewContext(), provider, track); EpisodeRepository episode = new(_NewContext(), show, provider, track);
UserRepository user = new(_NewContext()); UserRepository user = new(_NewContext());
LibraryManager = new LibraryManager(new IBaseRepository[] { LibraryManager = new LibraryManager(new IBaseRepository[] {

View File

@ -80,7 +80,7 @@ services:
- "8901:8901" - "8901:8901"
postgres: postgres:
image: "postgres" image: postgres:15
restart: on-failure restart: on-failure
env_file: env_file:
- ./.env - ./.env

View File

@ -58,7 +58,7 @@ services:
- "8901:8901" - "8901:8901"
postgres: postgres:
image: postgres image: postgres:15
restart: on-failure restart: on-failure
env_file: env_file:
- ./.env - ./.env

View File

@ -58,7 +58,7 @@ services:
- "8901:8901" - "8901:8901"
postgres: postgres:
image: postgres image: postgres:15
restart: on-failure restart: on-failure
env_file: env_file:
- ./.env - ./.env