diff --git a/.env.example b/.env.example index 5021a686..4a85ca47 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,13 @@ TVDB__APIKEY= THEMOVIEDB__APIKEY= AUTHENTICATION_SECRET= -POSTGRES_USER=kyoousername -POSTGRES_PASSWORD=kyoopassword -POSTGRES_DB=kyooDB PUBLIC_BACK_URL=http://localhost:5000 + +# Database things (optional) +POSTGRES_USER=KyooUser +POSTGRES_PASSWORD=KyooPassword +POSTGRES_DB=kyooDB +POSTGRES_SERVER=postgres +POSTGRES_PORT=5432 + +# vi: ft=sh diff --git a/back/Kyoo.sln b/back/Kyoo.sln index 9ebdae65..6a618cb7 100644 --- a/back/Kyoo.sln +++ b/back/Kyoo.sln @@ -3,14 +3,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kyoo.Core", "src\Kyoo.Core\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.Abstractions", "src\Kyoo.Abstractions\Kyoo.Abstractions.csproj", "{BAB2CAE1-AC28-4509-AA3E-8DC75BD59220}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.Database", "src\Kyoo.Database\Kyoo.Database.csproj", "{6F91B645-F785-46BB-9C4F-1EFC83E489B6}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.Postgresql", "src\Kyoo.Postgresql\Kyoo.Postgresql.csproj", "{3213C96D-0BF3-460B-A8B5-B9977229408A}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.Authentication", "src\Kyoo.Authentication\Kyoo.Authentication.csproj", "{7A841335-6523-47DB-9717-80AA7BD943FD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.SqLite", "src\Kyoo.SqLite\Kyoo.SqLite.csproj", "{6515380E-1E57-42DA-B6E3-E1C8A848818A}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.TheTvdb", "src\Kyoo.TheTvdb\Kyoo.TheTvdb.csproj", "{D06BF829-23F5-40F3-A62D-627D9F4B4D6C}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.TheMovieDb", "src\Kyoo.TheMovieDb\Kyoo.TheMovieDb.csproj", "{BAB270D4-E0EA-4329-BA65-512FDAB01001}" @@ -45,10 +41,6 @@ Global {BAB2CAE1-AC28-4509-AA3E-8DC75BD59220}.Debug|Any CPU.Build.0 = Debug|Any CPU {BAB2CAE1-AC28-4509-AA3E-8DC75BD59220}.Release|Any CPU.ActiveCfg = Release|Any CPU {BAB2CAE1-AC28-4509-AA3E-8DC75BD59220}.Release|Any CPU.Build.0 = Release|Any CPU - {6F91B645-F785-46BB-9C4F-1EFC83E489B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6F91B645-F785-46BB-9C4F-1EFC83E489B6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6F91B645-F785-46BB-9C4F-1EFC83E489B6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6F91B645-F785-46BB-9C4F-1EFC83E489B6}.Release|Any CPU.Build.0 = Release|Any CPU {3213C96D-0BF3-460B-A8B5-B9977229408A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3213C96D-0BF3-460B-A8B5-B9977229408A}.Debug|Any CPU.Build.0 = Debug|Any CPU {3213C96D-0BF3-460B-A8B5-B9977229408A}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -98,7 +90,6 @@ Global {0C8AA7EA-E723-4532-852F-35AA4E8AFED5} = {FEAE1B0E-D797-470F-9030-0EF743575ECC} {BAB270D4-E0EA-4329-BA65-512FDAB01001} = {8D28F5EF-0CD7-4697-A2A7-24EC31A48F21} {D06BF829-23F5-40F3-A62D-627D9F4B4D6C} = {8D28F5EF-0CD7-4697-A2A7-24EC31A48F21} - {6F91B645-F785-46BB-9C4F-1EFC83E489B6} = {865461CA-EC06-4B42-91CF-8723B0A9BB67} {3213C96D-0BF3-460B-A8B5-B9977229408A} = {865461CA-EC06-4B42-91CF-8723B0A9BB67} {6515380E-1E57-42DA-B6E3-E1C8A848818A} = {865461CA-EC06-4B42-91CF-8723B0A9BB67} {D8658BEA-8949-45AC-BEBB-A4FFC4F800F5} = {C569FF25-7E01-484C-9F72-5B99845AD94B} diff --git a/back/src/Kyoo.Core/Controllers/PassthroughPermissionValidator.cs b/back/src/Kyoo.Core/Controllers/PassthroughPermissionValidator.cs deleted file mode 100644 index 2c5ae6aa..00000000 --- a/back/src/Kyoo.Core/Controllers/PassthroughPermissionValidator.cs +++ /dev/null @@ -1,60 +0,0 @@ -// 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 . - -using System.Diagnostics.CodeAnalysis; -using Kyoo.Abstractions.Controllers; -using Kyoo.Abstractions.Models.Permissions; -using Microsoft.AspNetCore.Mvc.Filters; -using Microsoft.Extensions.Logging; - -namespace Kyoo.Core.Controllers -{ - /// - /// A permission validator that always validate permissions. This effectively disable the permission system. - /// - public class PassthroughPermissionValidator : IPermissionValidator - { - /// - /// Create a new . - /// - /// The logger used to warn that no real permission validator exists. - [SuppressMessage("ReSharper", "SuggestBaseTypeForParameterInConstructor", - Justification = "ILogger should include the typeparam for context.")] - public PassthroughPermissionValidator(ILogger logger) - { - logger.LogWarning("No permission validator has been enabled, all users will have all permissions"); - } - - /// - public IFilterMetadata Create(PermissionAttribute attribute) - { - return new PassthroughValidator(); - } - - /// - public IFilterMetadata Create(PartialPermissionAttribute attribute) - { - return new PassthroughValidator(); - } - - /// - /// An useless filter that does nothing. - /// - private class PassthroughValidator : IFilterMetadata { } - } -} diff --git a/back/src/Kyoo.Core/Controllers/Repositories/CollectionRepository.cs b/back/src/Kyoo.Core/Controllers/Repositories/CollectionRepository.cs index 0e6f4daa..840fbffd 100644 --- a/back/src/Kyoo.Core/Controllers/Repositories/CollectionRepository.cs +++ b/back/src/Kyoo.Core/Controllers/Repositories/CollectionRepository.cs @@ -22,7 +22,7 @@ using System.Linq; using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; -using Kyoo.Database; +using Kyoo.Postgresql; using Microsoft.EntityFrameworkCore; namespace Kyoo.Core.Controllers diff --git a/back/src/Kyoo.Core/Controllers/Repositories/EpisodeRepository.cs b/back/src/Kyoo.Core/Controllers/Repositories/EpisodeRepository.cs index 64650cf4..0bc73f6b 100644 --- a/back/src/Kyoo.Core/Controllers/Repositories/EpisodeRepository.cs +++ b/back/src/Kyoo.Core/Controllers/Repositories/EpisodeRepository.cs @@ -23,7 +23,7 @@ using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Exceptions; -using Kyoo.Database; +using Kyoo.Postgresql; using Kyoo.Utils; using Microsoft.EntityFrameworkCore; diff --git a/back/src/Kyoo.Core/Controllers/Repositories/GenreRepository.cs b/back/src/Kyoo.Core/Controllers/Repositories/GenreRepository.cs index 5c7a070b..2ada5abc 100644 --- a/back/src/Kyoo.Core/Controllers/Repositories/GenreRepository.cs +++ b/back/src/Kyoo.Core/Controllers/Repositories/GenreRepository.cs @@ -19,11 +19,10 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Linq.Expressions; using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; -using Kyoo.Database; +using Kyoo.Postgresql; using Microsoft.EntityFrameworkCore; namespace Kyoo.Core.Controllers diff --git a/back/src/Kyoo.Core/Controllers/Repositories/LibraryItemRepository.cs b/back/src/Kyoo.Core/Controllers/Repositories/LibraryItemRepository.cs index 61ecc099..a9b15fb5 100644 --- a/back/src/Kyoo.Core/Controllers/Repositories/LibraryItemRepository.cs +++ b/back/src/Kyoo.Core/Controllers/Repositories/LibraryItemRepository.cs @@ -24,7 +24,7 @@ using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Exceptions; -using Kyoo.Database; +using Kyoo.Postgresql; using Microsoft.EntityFrameworkCore; namespace Kyoo.Core.Controllers diff --git a/back/src/Kyoo.Core/Controllers/Repositories/LibraryRepository.cs b/back/src/Kyoo.Core/Controllers/Repositories/LibraryRepository.cs index 5177e120..c9987a3b 100644 --- a/back/src/Kyoo.Core/Controllers/Repositories/LibraryRepository.cs +++ b/back/src/Kyoo.Core/Controllers/Repositories/LibraryRepository.cs @@ -19,11 +19,10 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Linq.Expressions; using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; -using Kyoo.Database; +using Kyoo.Postgresql; using Kyoo.Utils; using Microsoft.EntityFrameworkCore; diff --git a/back/src/Kyoo.Core/Controllers/Repositories/PeopleRepository.cs b/back/src/Kyoo.Core/Controllers/Repositories/PeopleRepository.cs index d14f0048..70a06b3d 100644 --- a/back/src/Kyoo.Core/Controllers/Repositories/PeopleRepository.cs +++ b/back/src/Kyoo.Core/Controllers/Repositories/PeopleRepository.cs @@ -23,8 +23,7 @@ using System.Linq.Expressions; using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; -using Kyoo.Abstractions.Models.Exceptions; -using Kyoo.Database; +using Kyoo.Postgresql; using Kyoo.Utils; using Microsoft.EntityFrameworkCore; diff --git a/back/src/Kyoo.Core/Controllers/Repositories/ProviderRepository.cs b/back/src/Kyoo.Core/Controllers/Repositories/ProviderRepository.cs index 08389693..5aa2d0be 100644 --- a/back/src/Kyoo.Core/Controllers/Repositories/ProviderRepository.cs +++ b/back/src/Kyoo.Core/Controllers/Repositories/ProviderRepository.cs @@ -23,7 +23,7 @@ using System.Linq.Expressions; using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; -using Kyoo.Database; +using Kyoo.Postgresql; using Microsoft.EntityFrameworkCore; namespace Kyoo.Core.Controllers diff --git a/back/src/Kyoo.Core/Controllers/Repositories/SeasonRepository.cs b/back/src/Kyoo.Core/Controllers/Repositories/SeasonRepository.cs index 7dcd9845..8dc193c5 100644 --- a/back/src/Kyoo.Core/Controllers/Repositories/SeasonRepository.cs +++ b/back/src/Kyoo.Core/Controllers/Repositories/SeasonRepository.cs @@ -19,12 +19,11 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Linq.Expressions; using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; using Kyoo.Abstractions.Models.Exceptions; -using Kyoo.Database; +using Kyoo.Postgresql; using Microsoft.EntityFrameworkCore; namespace Kyoo.Core.Controllers diff --git a/back/src/Kyoo.Core/Controllers/Repositories/ShowRepository.cs b/back/src/Kyoo.Core/Controllers/Repositories/ShowRepository.cs index a2d26da1..14802bea 100644 --- a/back/src/Kyoo.Core/Controllers/Repositories/ShowRepository.cs +++ b/back/src/Kyoo.Core/Controllers/Repositories/ShowRepository.cs @@ -16,14 +16,12 @@ // You should have received a copy of the GNU General Public License // along with Kyoo. If not, see . -using System; using System.Collections.Generic; using System.Linq; -using System.Linq.Expressions; using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; -using Kyoo.Database; +using Kyoo.Postgresql; using Kyoo.Utils; using Microsoft.EntityFrameworkCore; diff --git a/back/src/Kyoo.Core/Controllers/Repositories/StudioRepository.cs b/back/src/Kyoo.Core/Controllers/Repositories/StudioRepository.cs index 3c4acc3a..78cccbdb 100644 --- a/back/src/Kyoo.Core/Controllers/Repositories/StudioRepository.cs +++ b/back/src/Kyoo.Core/Controllers/Repositories/StudioRepository.cs @@ -19,11 +19,10 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Linq.Expressions; using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; -using Kyoo.Database; +using Kyoo.Postgresql; using Microsoft.EntityFrameworkCore; namespace Kyoo.Core.Controllers diff --git a/back/src/Kyoo.Core/Controllers/Repositories/TrackRepository.cs b/back/src/Kyoo.Core/Controllers/Repositories/TrackRepository.cs index 2528fc2b..4c55cc47 100644 --- a/back/src/Kyoo.Core/Controllers/Repositories/TrackRepository.cs +++ b/back/src/Kyoo.Core/Controllers/Repositories/TrackRepository.cs @@ -21,7 +21,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; -using Kyoo.Database; +using Kyoo.Postgresql; using Microsoft.EntityFrameworkCore; namespace Kyoo.Core.Controllers diff --git a/back/src/Kyoo.Core/Controllers/Repositories/UserRepository.cs b/back/src/Kyoo.Core/Controllers/Repositories/UserRepository.cs index 68835752..0ff386e5 100644 --- a/back/src/Kyoo.Core/Controllers/Repositories/UserRepository.cs +++ b/back/src/Kyoo.Core/Controllers/Repositories/UserRepository.cs @@ -19,11 +19,10 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Linq.Expressions; using System.Threading.Tasks; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models; -using Kyoo.Database; +using Kyoo.Postgresql; using Microsoft.EntityFrameworkCore; namespace Kyoo.Core.Controllers diff --git a/back/src/Kyoo.Core/CoreModule.cs b/back/src/Kyoo.Core/CoreModule.cs index 9b775511..3366c80b 100644 --- a/back/src/Kyoo.Core/CoreModule.cs +++ b/back/src/Kyoo.Core/CoreModule.cs @@ -20,15 +20,12 @@ using System; using System.Collections.Generic; using System.Linq; using Autofac; -using Autofac.Core; -using Autofac.Core.Registration; using Kyoo.Abstractions; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models.Utils; using Kyoo.Core.Controllers; using Kyoo.Core.Models.Options; using Kyoo.Core.Tasks; -using Kyoo.Database; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Routing; @@ -85,24 +82,18 @@ namespace Kyoo.Core builder.RegisterTask(); builder.RegisterTask(); - static bool DatabaseIsPresent(IComponentRegistryBuilder x) - => x.IsRegistered(new TypedService(typeof(DatabaseContext))); - - builder.RegisterRepository().OnlyIf(DatabaseIsPresent); - builder.RegisterRepository().OnlyIf(DatabaseIsPresent); - builder.RegisterRepository().OnlyIf(DatabaseIsPresent); - builder.RegisterRepository().OnlyIf(DatabaseIsPresent); - builder.RegisterRepository().OnlyIf(DatabaseIsPresent); - builder.RegisterRepository().OnlyIf(DatabaseIsPresent); - builder.RegisterRepository().OnlyIf(DatabaseIsPresent); - builder.RegisterRepository().OnlyIf(DatabaseIsPresent); - builder.RegisterRepository().OnlyIf(DatabaseIsPresent); - builder.RegisterRepository().OnlyIf(DatabaseIsPresent); - builder.RegisterRepository().OnlyIf(DatabaseIsPresent); - builder.RegisterRepository().OnlyIf(DatabaseIsPresent); - - builder.RegisterType().As() - .IfNotRegistered(typeof(IPermissionValidator)); + builder.RegisterRepository(); + builder.RegisterRepository(); + builder.RegisterRepository(); + builder.RegisterRepository(); + builder.RegisterRepository(); + builder.RegisterRepository(); + builder.RegisterRepository(); + builder.RegisterRepository(); + builder.RegisterRepository(); + builder.RegisterRepository(); + builder.RegisterRepository(); + builder.RegisterRepository(); builder.RegisterType().As().SingleInstance() .OnActivating(x => diff --git a/back/src/Kyoo.Core/Kyoo.Core.csproj b/back/src/Kyoo.Core/Kyoo.Core.csproj index 740fff1e..8f113039 100644 --- a/back/src/Kyoo.Core/Kyoo.Core.csproj +++ b/back/src/Kyoo.Core/Kyoo.Core.csproj @@ -19,7 +19,7 @@ - + diff --git a/back/src/Kyoo.Database/Extensions.cs b/back/src/Kyoo.Database/Extensions.cs deleted file mode 100644 index f7f75850..00000000 --- a/back/src/Kyoo.Database/Extensions.cs +++ /dev/null @@ -1,65 +0,0 @@ -// 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 . - -using System.Data.Common; -using Microsoft.Extensions.Configuration; - -namespace Kyoo.Database -{ - /// - /// A class that regroup extensions used by some asp-net related parts of the app. - /// - public static class Extensions - { - /// - /// Get a connection string from the Configuration's section "Database" - /// - /// The IConfiguration instance to use. - /// The database's name. - /// A parsed connection string - public static string GetDatabaseConnection(this IConfiguration config, string database) - { - static string ToDbProperty(string key) - { - return key.ToUpperInvariant() switch - { - "USER" => "USER ID", - _ => key - }; - } - - DbConnectionStringBuilder builder = new(); - IConfigurationSection section = config.GetSection("database:configurations").GetSection(database); - foreach (IConfigurationSection child in section.GetChildren()) - { - builder[ToDbProperty(child.Key)] = child.Value; - } - return builder.ConnectionString; - } - - /// - /// Get the name of the selected database. - /// - /// The IConfiguration instance to use. - /// The name of the selected database. - public static string GetSelectedDatabase(this IConfiguration config) - { - return config.GetValue("database:enabled"); - } - } -} diff --git a/back/src/Kyoo.Database/Kyoo.Database.csproj b/back/src/Kyoo.Database/Kyoo.Database.csproj deleted file mode 100644 index b02d0279..00000000 --- a/back/src/Kyoo.Database/Kyoo.Database.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - Kyoo.Database - Kyoo.Database - - - - - - - - - - - - - diff --git a/back/src/Kyoo.Host.Generic/Application.cs b/back/src/Kyoo.Host.Generic/Application.cs index 62cca55e..cb1e0f9b 100644 --- a/back/src/Kyoo.Host.Generic/Application.cs +++ b/back/src/Kyoo.Host.Generic/Application.cs @@ -17,7 +17,6 @@ // along with Kyoo. If not, see . using System; -using System.Collections.Generic; using System.IO; using System.Reflection; using System.Threading; @@ -32,7 +31,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting.Systemd; using Microsoft.Extensions.Logging; -using Microsoft.Win32; using Serilog; using Serilog.Templates; using Serilog.Templates.Themes; diff --git a/back/src/Kyoo.Host.Generic/PluginsStartup.cs b/back/src/Kyoo.Host.Generic/PluginsStartup.cs index a5707773..63bc88cc 100644 --- a/back/src/Kyoo.Host.Generic/PluginsStartup.cs +++ b/back/src/Kyoo.Host.Generic/PluginsStartup.cs @@ -27,7 +27,6 @@ using Kyoo.Core; using Kyoo.Core.Models.Options; using Kyoo.Host.Generic.Controllers; using Kyoo.Postgresql; -using Kyoo.SqLite; using Kyoo.Swagger; using Kyoo.TheMovieDb; using Kyoo.TheTvdb; @@ -78,7 +77,6 @@ namespace Kyoo.Host.Generic typeof(CoreModule), typeof(AuthenticationModule), typeof(PostgresModule), - typeof(SqLiteModule), typeof(PluginTvdb), typeof(PluginTmdb), typeof(SwaggerModule) diff --git a/back/src/Kyoo.Host.Generic/settings.json b/back/src/Kyoo.Host.Generic/settings.json index 842060f6..0d5390cf 100644 --- a/back/src/Kyoo.Host.Generic/settings.json +++ b/back/src/Kyoo.Host.Generic/settings.json @@ -7,26 +7,6 @@ "metadataPath": "metadata/" }, - "database": { - "enabled": "sqlite", - "configurations": { - "sqlite": { - "data Source": "kyoo.db", - "cache": "Shared" - }, - "postgres": { - "server": "127.0.0.1", - "port": "5432", - "database": "kyooDB", - "user": "kyoo", - "password": "kyooPassword", - "pooling": "true", - "maxPoolSize": "95", - "timeout": "30" - } - } - }, - "logging": { "MinimumLevel": { "Default": "Warning", diff --git a/back/src/Kyoo.Database/DatabaseContext.cs b/back/src/Kyoo.Postgresql/DatabaseContext.cs similarity index 99% rename from back/src/Kyoo.Database/DatabaseContext.cs rename to back/src/Kyoo.Postgresql/DatabaseContext.cs index 12cb22d4..fb3886df 100644 --- a/back/src/Kyoo.Database/DatabaseContext.cs +++ b/back/src/Kyoo.Postgresql/DatabaseContext.cs @@ -29,7 +29,7 @@ using Kyoo.Abstractions.Models.Exceptions; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.ChangeTracking; -namespace Kyoo.Database +namespace Kyoo.Postgresql { /// /// The database handle used for all local repositories. diff --git a/back/src/Kyoo.Postgresql/Kyoo.Postgresql.csproj b/back/src/Kyoo.Postgresql/Kyoo.Postgresql.csproj index 85ce27db..442c8c8f 100644 --- a/back/src/Kyoo.Postgresql/Kyoo.Postgresql.csproj +++ b/back/src/Kyoo.Postgresql/Kyoo.Postgresql.csproj @@ -11,10 +11,10 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + - diff --git a/back/src/Kyoo.Postgresql/PostgresContext.cs b/back/src/Kyoo.Postgresql/PostgresContext.cs index ee29d437..49ecf3ce 100644 --- a/back/src/Kyoo.Postgresql/PostgresContext.cs +++ b/back/src/Kyoo.Postgresql/PostgresContext.cs @@ -22,7 +22,6 @@ using System.Linq.Expressions; using System.Reflection; using EFCore.NamingConventions.Internal; using Kyoo.Abstractions.Models; -using Kyoo.Database; using Kyoo.Utils; using Microsoft.EntityFrameworkCore; using Npgsql; diff --git a/back/src/Kyoo.Postgresql/PostgresModule.cs b/back/src/Kyoo.Postgresql/PostgresModule.cs index ebe200eb..fbcb3bfa 100644 --- a/back/src/Kyoo.Postgresql/PostgresModule.cs +++ b/back/src/Kyoo.Postgresql/PostgresModule.cs @@ -18,8 +18,8 @@ using System; using System.Collections.Generic; +using System.Data.Common; using Kyoo.Abstractions.Controllers; -using Kyoo.Database; using Microsoft.AspNetCore.Hosting; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; @@ -47,7 +47,7 @@ namespace Kyoo.Postgresql public Dictionary Configuration => new(); /// - public bool Enabled => _configuration.GetSelectedDatabase() == "postgres"; + public bool Enabled => true; /// /// The configuration to use. The database connection string is pulled from it. @@ -75,7 +75,18 @@ namespace Kyoo.Postgresql { services.AddDbContext(x => { - x.UseNpgsql(_configuration.GetDatabaseConnection("postgres")); + DbConnectionStringBuilder builder = new() + { + ["USER ID"] = _configuration.GetValue("POSTGRES_USER", "KyooUser"), + ["PASSWORD"] = _configuration.GetValue("POSTGRES_PASSWORD", "KyooPassword"), + ["SERVER"] = _configuration.GetValue("POSTGRES_SERVER", "db"), + ["PORT"] = _configuration.GetValue("POSTGRES_PORT", "5432"), + ["DATABASE"] = _configuration.GetValue("POSTGRES_DB", "kyooDB"), + ["POOLING"] = "true", + ["MAXPOOLSIZE"] = "95", + ["TIMEOUT"] = "30" + }; + x.UseNpgsql(builder.ConnectionString); if (_environment.IsDevelopment()) x.EnableDetailedErrors().EnableSensitiveDataLogging(); }, ServiceLifetime.Transient); diff --git a/back/src/Kyoo.SqLite/Kyoo.SqLite.csproj b/back/src/Kyoo.SqLite/Kyoo.SqLite.csproj deleted file mode 100644 index b999e5f6..00000000 --- a/back/src/Kyoo.SqLite/Kyoo.SqLite.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - Kyoo.SqLite - Kyoo.SqLite - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - diff --git a/back/src/Kyoo.SqLite/Migrations/20210801171534_Initial.Designer.cs b/back/src/Kyoo.SqLite/Migrations/20210801171534_Initial.Designer.cs deleted file mode 100644 index e912d60a..00000000 --- a/back/src/Kyoo.SqLite/Migrations/20210801171534_Initial.Designer.cs +++ /dev/null @@ -1,1020 +0,0 @@ -// -using System; -using Kyoo.SqLite; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -namespace Kyoo.SqLite.Migrations -{ - [DbContext(typeof(SqLiteContext))] - [Migration("20210801171534_Initial")] - partial class Initial - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "5.0.8"); - - modelBuilder.Entity("CollectionMetadataID", b => - { - b.Property("ResourceID") - .HasColumnType("INTEGER"); - - b.Property("ProviderID") - .HasColumnType("INTEGER"); - - b.Property("DataID") - .HasColumnType("TEXT"); - - b.Property("Link") - .HasColumnType("TEXT"); - - b.HasKey("ResourceID", "ProviderID"); - - b.HasIndex("ProviderID"); - - b.ToTable("CollectionMetadataID"); - }); - - modelBuilder.Entity("EpisodeMetadataID", b => - { - b.Property("ResourceID") - .HasColumnType("INTEGER"); - - b.Property("ProviderID") - .HasColumnType("INTEGER"); - - b.Property("DataID") - .HasColumnType("TEXT"); - - b.Property("Link") - .HasColumnType("TEXT"); - - b.HasKey("ResourceID", "ProviderID"); - - b.HasIndex("ProviderID"); - - b.ToTable("EpisodeMetadataID"); - }); - - modelBuilder.Entity("Kyoo.Models.Collection", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Images") - .HasColumnType("TEXT"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Overview") - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.ToTable("Collections"); - }); - - modelBuilder.Entity("Kyoo.Models.Episode", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("AbsoluteNumber") - .HasColumnType("INTEGER"); - - b.Property("EpisodeNumber") - .HasColumnType("INTEGER"); - - b.Property("Images") - .HasColumnType("TEXT"); - - b.Property("Overview") - .HasColumnType("TEXT"); - - b.Property("Path") - .HasColumnType("TEXT"); - - b.Property("ReleaseDate") - .HasColumnType("TEXT"); - - b.Property("SeasonID") - .HasColumnType("INTEGER"); - - b.Property("SeasonNumber") - .HasColumnType("INTEGER"); - - b.Property("ShowID") - .HasColumnType("INTEGER"); - - b.Property("Slug") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TEXT"); - - b.Property("Title") - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("SeasonID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.HasIndex("ShowID", "SeasonNumber", "EpisodeNumber", "AbsoluteNumber") - .IsUnique(); - - b.ToTable("Episodes"); - }); - - modelBuilder.Entity("Kyoo.Models.Genre", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.ToTable("Genres"); - }); - - modelBuilder.Entity("Kyoo.Models.Library", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Paths") - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.ToTable("Libraries"); - }); - - modelBuilder.Entity("Kyoo.Models.LibraryItem", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("EndAir") - .HasColumnType("TEXT"); - - b.Property("Images") - .HasColumnType("TEXT"); - - b.Property("Overview") - .HasColumnType("TEXT"); - - b.Property("Slug") - .HasColumnType("TEXT"); - - b.Property("StartAir") - .HasColumnType("TEXT"); - - b.Property("Status") - .HasColumnType("INTEGER"); - - b.Property("Title") - .HasColumnType("TEXT"); - - b.Property("Type") - .HasColumnType("INTEGER"); - - b.HasKey("ID"); - - b.ToView("LibraryItems"); - }); - - modelBuilder.Entity("Kyoo.Models.People", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Images") - .HasColumnType("TEXT"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.ToTable("People"); - }); - - modelBuilder.Entity("Kyoo.Models.PeopleRole", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("PeopleID") - .HasColumnType("INTEGER"); - - b.Property("Role") - .HasColumnType("TEXT"); - - b.Property("ShowID") - .HasColumnType("INTEGER"); - - b.Property("Type") - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("PeopleID"); - - b.HasIndex("ShowID"); - - b.ToTable("PeopleRoles"); - }); - - modelBuilder.Entity("Kyoo.Models.Provider", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Images") - .HasColumnType("TEXT"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.ToTable("Providers"); - }); - - modelBuilder.Entity("Kyoo.Models.Season", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("EndDate") - .HasColumnType("TEXT"); - - b.Property("Images") - .HasColumnType("TEXT"); - - b.Property("Overview") - .HasColumnType("TEXT"); - - b.Property("SeasonNumber") - .HasColumnType("INTEGER"); - - b.Property("ShowID") - .HasColumnType("INTEGER"); - - b.Property("Slug") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TEXT"); - - b.Property("StartDate") - .HasColumnType("TEXT"); - - b.Property("Title") - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.HasIndex("ShowID", "SeasonNumber") - .IsUnique(); - - b.ToTable("Seasons"); - }); - - modelBuilder.Entity("Kyoo.Models.Show", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Aliases") - .HasColumnType("TEXT"); - - b.Property("EndAir") - .HasColumnType("TEXT"); - - b.Property("Images") - .HasColumnType("TEXT"); - - b.Property("IsMovie") - .HasColumnType("INTEGER"); - - b.Property("Overview") - .HasColumnType("TEXT"); - - b.Property("Path") - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("StartAir") - .HasColumnType("TEXT"); - - b.Property("Status") - .HasColumnType("INTEGER"); - - b.Property("StudioID") - .HasColumnType("INTEGER"); - - b.Property("Title") - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.HasIndex("StudioID"); - - b.ToTable("Shows"); - }); - - modelBuilder.Entity("Kyoo.Models.Studio", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.ToTable("Studios"); - }); - - modelBuilder.Entity("Kyoo.Models.Track", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Codec") - .HasColumnType("TEXT"); - - b.Property("EpisodeID") - .HasColumnType("INTEGER"); - - b.Property("IsDefault") - .HasColumnType("INTEGER"); - - b.Property("IsExternal") - .HasColumnType("INTEGER"); - - b.Property("IsForced") - .HasColumnType("INTEGER"); - - b.Property("Language") - .HasColumnType("TEXT"); - - b.Property("Path") - .HasColumnType("TEXT"); - - b.Property("Slug") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TEXT"); - - b.Property("Title") - .HasColumnType("TEXT"); - - b.Property("TrackIndex") - .HasColumnType("INTEGER"); - - b.Property("Type") - .HasColumnType("INTEGER"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.HasIndex("EpisodeID", "Type", "Language", "TrackIndex", "IsForced") - .IsUnique(); - - b.ToTable("Tracks"); - }); - - modelBuilder.Entity("Kyoo.Models.User", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Email") - .HasColumnType("TEXT"); - - b.Property("ExtraData") - .HasColumnType("TEXT"); - - b.Property("Images") - .HasColumnType("TEXT"); - - b.Property("Password") - .HasColumnType("TEXT"); - - b.Property("Permissions") - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Username") - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Kyoo.Models.WatchedEpisode", b => - { - b.Property("UserID") - .HasColumnType("INTEGER"); - - b.Property("EpisodeID") - .HasColumnType("INTEGER"); - - b.Property("WatchedPercentage") - .HasColumnType("INTEGER"); - - b.HasKey("UserID", "EpisodeID"); - - b.HasIndex("EpisodeID"); - - b.ToTable("WatchedEpisodes"); - }); - - modelBuilder.Entity("LinkCollectionShow", b => - { - b.Property("CollectionID") - .HasColumnType("INTEGER"); - - b.Property("ShowID") - .HasColumnType("INTEGER"); - - b.HasKey("CollectionID", "ShowID"); - - b.HasIndex("ShowID"); - - b.ToTable("LinkCollectionShow"); - }); - - modelBuilder.Entity("LinkLibraryCollection", b => - { - b.Property("CollectionID") - .HasColumnType("INTEGER"); - - b.Property("LibraryID") - .HasColumnType("INTEGER"); - - b.HasKey("CollectionID", "LibraryID"); - - b.HasIndex("LibraryID"); - - b.ToTable("LinkLibraryCollection"); - }); - - modelBuilder.Entity("LinkLibraryProvider", b => - { - b.Property("LibraryID") - .HasColumnType("INTEGER"); - - b.Property("ProviderID") - .HasColumnType("INTEGER"); - - b.HasKey("LibraryID", "ProviderID"); - - b.HasIndex("ProviderID"); - - b.ToTable("LinkLibraryProvider"); - }); - - modelBuilder.Entity("LinkLibraryShow", b => - { - b.Property("LibraryID") - .HasColumnType("INTEGER"); - - b.Property("ShowID") - .HasColumnType("INTEGER"); - - b.HasKey("LibraryID", "ShowID"); - - b.HasIndex("ShowID"); - - b.ToTable("LinkLibraryShow"); - }); - - modelBuilder.Entity("LinkShowGenre", b => - { - b.Property("GenreID") - .HasColumnType("INTEGER"); - - b.Property("ShowID") - .HasColumnType("INTEGER"); - - b.HasKey("GenreID", "ShowID"); - - b.HasIndex("ShowID"); - - b.ToTable("LinkShowGenre"); - }); - - modelBuilder.Entity("PeopleMetadataID", b => - { - b.Property("ResourceID") - .HasColumnType("INTEGER"); - - b.Property("ProviderID") - .HasColumnType("INTEGER"); - - b.Property("DataID") - .HasColumnType("TEXT"); - - b.Property("Link") - .HasColumnType("TEXT"); - - b.HasKey("ResourceID", "ProviderID"); - - b.HasIndex("ProviderID"); - - b.ToTable("PeopleMetadataID"); - }); - - modelBuilder.Entity("SeasonMetadataID", b => - { - b.Property("ResourceID") - .HasColumnType("INTEGER"); - - b.Property("ProviderID") - .HasColumnType("INTEGER"); - - b.Property("DataID") - .HasColumnType("TEXT"); - - b.Property("Link") - .HasColumnType("TEXT"); - - b.HasKey("ResourceID", "ProviderID"); - - b.HasIndex("ProviderID"); - - b.ToTable("SeasonMetadataID"); - }); - - modelBuilder.Entity("ShowMetadataID", b => - { - b.Property("ResourceID") - .HasColumnType("INTEGER"); - - b.Property("ProviderID") - .HasColumnType("INTEGER"); - - b.Property("DataID") - .HasColumnType("TEXT"); - - b.Property("Link") - .HasColumnType("TEXT"); - - b.HasKey("ResourceID", "ProviderID"); - - b.HasIndex("ProviderID"); - - b.ToTable("ShowMetadataID"); - }); - - modelBuilder.Entity("ShowUser", b => - { - b.Property("UsersID") - .HasColumnType("INTEGER"); - - b.Property("WatchedID") - .HasColumnType("INTEGER"); - - b.HasKey("UsersID", "WatchedID"); - - b.HasIndex("WatchedID"); - - b.ToTable("LinkUserShow"); - }); - - modelBuilder.Entity("StudioMetadataID", b => - { - b.Property("ResourceID") - .HasColumnType("INTEGER"); - - b.Property("ProviderID") - .HasColumnType("INTEGER"); - - b.Property("DataID") - .HasColumnType("TEXT"); - - b.Property("Link") - .HasColumnType("TEXT"); - - b.HasKey("ResourceID", "ProviderID"); - - b.HasIndex("ProviderID"); - - b.ToTable("StudioMetadataID"); - }); - - modelBuilder.Entity("CollectionMetadataID", b => - { - b.HasOne("Kyoo.Models.Provider", "Provider") - .WithMany() - .HasForeignKey("ProviderID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Collection", null) - .WithMany("ExternalIDs") - .HasForeignKey("ResourceID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Provider"); - }); - - modelBuilder.Entity("EpisodeMetadataID", b => - { - b.HasOne("Kyoo.Models.Provider", "Provider") - .WithMany() - .HasForeignKey("ProviderID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Episode", null) - .WithMany("ExternalIDs") - .HasForeignKey("ResourceID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Provider"); - }); - - modelBuilder.Entity("Kyoo.Models.Episode", b => - { - b.HasOne("Kyoo.Models.Season", "Season") - .WithMany("Episodes") - .HasForeignKey("SeasonID") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("Kyoo.Models.Show", "Show") - .WithMany("Episodes") - .HasForeignKey("ShowID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Season"); - - b.Navigation("Show"); - }); - - modelBuilder.Entity("Kyoo.Models.PeopleRole", b => - { - b.HasOne("Kyoo.Models.People", "People") - .WithMany("Roles") - .HasForeignKey("PeopleID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Show", "Show") - .WithMany("People") - .HasForeignKey("ShowID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("People"); - - b.Navigation("Show"); - }); - - modelBuilder.Entity("Kyoo.Models.Season", b => - { - b.HasOne("Kyoo.Models.Show", "Show") - .WithMany("Seasons") - .HasForeignKey("ShowID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Show"); - }); - - modelBuilder.Entity("Kyoo.Models.Show", b => - { - b.HasOne("Kyoo.Models.Studio", "Studio") - .WithMany("Shows") - .HasForeignKey("StudioID") - .OnDelete(DeleteBehavior.SetNull); - - b.Navigation("Studio"); - }); - - modelBuilder.Entity("Kyoo.Models.Track", b => - { - b.HasOne("Kyoo.Models.Episode", "Episode") - .WithMany("Tracks") - .HasForeignKey("EpisodeID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Episode"); - }); - - modelBuilder.Entity("Kyoo.Models.WatchedEpisode", b => - { - b.HasOne("Kyoo.Models.Episode", "Episode") - .WithMany() - .HasForeignKey("EpisodeID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.User", null) - .WithMany("CurrentlyWatching") - .HasForeignKey("UserID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Episode"); - }); - - modelBuilder.Entity("LinkCollectionShow", b => - { - b.HasOne("Kyoo.Models.Collection", null) - .WithMany() - .HasForeignKey("CollectionID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Show", null) - .WithMany() - .HasForeignKey("ShowID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("LinkLibraryCollection", b => - { - b.HasOne("Kyoo.Models.Collection", null) - .WithMany() - .HasForeignKey("CollectionID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Library", null) - .WithMany() - .HasForeignKey("LibraryID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("LinkLibraryProvider", b => - { - b.HasOne("Kyoo.Models.Library", null) - .WithMany() - .HasForeignKey("LibraryID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Provider", null) - .WithMany() - .HasForeignKey("ProviderID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("LinkLibraryShow", b => - { - b.HasOne("Kyoo.Models.Library", null) - .WithMany() - .HasForeignKey("LibraryID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Show", null) - .WithMany() - .HasForeignKey("ShowID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("LinkShowGenre", b => - { - b.HasOne("Kyoo.Models.Genre", null) - .WithMany() - .HasForeignKey("GenreID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Show", null) - .WithMany() - .HasForeignKey("ShowID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("PeopleMetadataID", b => - { - b.HasOne("Kyoo.Models.Provider", "Provider") - .WithMany() - .HasForeignKey("ProviderID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.People", null) - .WithMany("ExternalIDs") - .HasForeignKey("ResourceID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Provider"); - }); - - modelBuilder.Entity("SeasonMetadataID", b => - { - b.HasOne("Kyoo.Models.Provider", "Provider") - .WithMany() - .HasForeignKey("ProviderID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Season", null) - .WithMany("ExternalIDs") - .HasForeignKey("ResourceID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Provider"); - }); - - modelBuilder.Entity("ShowMetadataID", b => - { - b.HasOne("Kyoo.Models.Provider", "Provider") - .WithMany() - .HasForeignKey("ProviderID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Show", null) - .WithMany("ExternalIDs") - .HasForeignKey("ResourceID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Provider"); - }); - - modelBuilder.Entity("ShowUser", b => - { - b.HasOne("Kyoo.Models.User", null) - .WithMany() - .HasForeignKey("UsersID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Show", null) - .WithMany() - .HasForeignKey("WatchedID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("StudioMetadataID", b => - { - b.HasOne("Kyoo.Models.Provider", "Provider") - .WithMany() - .HasForeignKey("ProviderID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Studio", null) - .WithMany("ExternalIDs") - .HasForeignKey("ResourceID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Provider"); - }); - - modelBuilder.Entity("Kyoo.Models.Collection", b => - { - b.Navigation("ExternalIDs"); - }); - - modelBuilder.Entity("Kyoo.Models.Episode", b => - { - b.Navigation("ExternalIDs"); - - b.Navigation("Tracks"); - }); - - modelBuilder.Entity("Kyoo.Models.People", b => - { - b.Navigation("ExternalIDs"); - - b.Navigation("Roles"); - }); - - modelBuilder.Entity("Kyoo.Models.Season", b => - { - b.Navigation("Episodes"); - - b.Navigation("ExternalIDs"); - }); - - modelBuilder.Entity("Kyoo.Models.Show", b => - { - b.Navigation("Episodes"); - - b.Navigation("ExternalIDs"); - - b.Navigation("People"); - - b.Navigation("Seasons"); - }); - - modelBuilder.Entity("Kyoo.Models.Studio", b => - { - b.Navigation("ExternalIDs"); - - b.Navigation("Shows"); - }); - - modelBuilder.Entity("Kyoo.Models.User", b => - { - b.Navigation("CurrentlyWatching"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/back/src/Kyoo.SqLite/Migrations/20210801171534_Initial.cs b/back/src/Kyoo.SqLite/Migrations/20210801171534_Initial.cs deleted file mode 100644 index 985f0409..00000000 --- a/back/src/Kyoo.SqLite/Migrations/20210801171534_Initial.cs +++ /dev/null @@ -1,861 +0,0 @@ -// 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 . - -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace Kyoo.SqLite.Migrations -{ - /// - /// The initial migration that build most of the database. - /// - public partial class Initial : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Collections", - columns: table => new - { - ID = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Slug = table.Column(type: "TEXT", nullable: false), - Name = table.Column(type: "TEXT", nullable: true), - Images = table.Column(type: "TEXT", nullable: true), - Overview = table.Column(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Collections", x => x.ID); - }); - - migrationBuilder.CreateTable( - name: "Genres", - columns: table => new - { - ID = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Slug = table.Column(type: "TEXT", nullable: false), - Name = table.Column(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Genres", x => x.ID); - }); - - migrationBuilder.CreateTable( - name: "Libraries", - columns: table => new - { - ID = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Slug = table.Column(type: "TEXT", nullable: false), - Name = table.Column(type: "TEXT", nullable: true), - Paths = table.Column(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Libraries", x => x.ID); - }); - - migrationBuilder.CreateTable( - name: "People", - columns: table => new - { - ID = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Slug = table.Column(type: "TEXT", nullable: false), - Name = table.Column(type: "TEXT", nullable: true), - Images = table.Column(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_People", x => x.ID); - }); - - migrationBuilder.CreateTable( - name: "Providers", - columns: table => new - { - ID = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Slug = table.Column(type: "TEXT", nullable: false), - Name = table.Column(type: "TEXT", nullable: true), - Images = table.Column(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Providers", x => x.ID); - }); - - migrationBuilder.CreateTable( - name: "Studios", - columns: table => new - { - ID = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Slug = table.Column(type: "TEXT", nullable: false), - Name = table.Column(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Studios", x => x.ID); - }); - - migrationBuilder.CreateTable( - name: "Users", - columns: table => new - { - ID = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Slug = table.Column(type: "TEXT", nullable: false), - Username = table.Column(type: "TEXT", nullable: true), - Email = table.Column(type: "TEXT", nullable: true), - Password = table.Column(type: "TEXT", nullable: true), - Permissions = table.Column(type: "TEXT", nullable: true), - ExtraData = table.Column(type: "TEXT", nullable: true), - Images = table.Column(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Users", x => x.ID); - }); - - migrationBuilder.CreateTable( - name: "LinkLibraryCollection", - columns: table => new - { - CollectionID = table.Column(type: "INTEGER", nullable: false), - LibraryID = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_LinkLibraryCollection", x => new { x.CollectionID, x.LibraryID }); - table.ForeignKey( - name: "FK_LinkLibraryCollection_Collections_CollectionID", - column: x => x.CollectionID, - principalTable: "Collections", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_LinkLibraryCollection_Libraries_LibraryID", - column: x => x.LibraryID, - principalTable: "Libraries", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "CollectionMetadataID", - columns: table => new - { - ResourceID = table.Column(type: "INTEGER", nullable: false), - ProviderID = table.Column(type: "INTEGER", nullable: false), - DataID = table.Column(type: "TEXT", nullable: true), - Link = table.Column(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CollectionMetadataID", x => new { x.ResourceID, x.ProviderID }); - table.ForeignKey( - name: "FK_CollectionMetadataID_Collections_ResourceID", - column: x => x.ResourceID, - principalTable: "Collections", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_CollectionMetadataID_Providers_ProviderID", - column: x => x.ProviderID, - principalTable: "Providers", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "LinkLibraryProvider", - columns: table => new - { - LibraryID = table.Column(type: "INTEGER", nullable: false), - ProviderID = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_LinkLibraryProvider", x => new { x.LibraryID, x.ProviderID }); - table.ForeignKey( - name: "FK_LinkLibraryProvider_Libraries_LibraryID", - column: x => x.LibraryID, - principalTable: "Libraries", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_LinkLibraryProvider_Providers_ProviderID", - column: x => x.ProviderID, - principalTable: "Providers", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "PeopleMetadataID", - columns: table => new - { - ResourceID = table.Column(type: "INTEGER", nullable: false), - ProviderID = table.Column(type: "INTEGER", nullable: false), - DataID = table.Column(type: "TEXT", nullable: true), - Link = table.Column(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_PeopleMetadataID", x => new { x.ResourceID, x.ProviderID }); - table.ForeignKey( - name: "FK_PeopleMetadataID_People_ResourceID", - column: x => x.ResourceID, - principalTable: "People", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_PeopleMetadataID_Providers_ProviderID", - column: x => x.ProviderID, - principalTable: "Providers", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Shows", - columns: table => new - { - ID = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Slug = table.Column(type: "TEXT", nullable: false), - Title = table.Column(type: "TEXT", nullable: true), - Aliases = table.Column(type: "TEXT", nullable: true), - Path = table.Column(type: "TEXT", nullable: true), - Overview = table.Column(type: "TEXT", nullable: true), - Status = table.Column(type: "INTEGER", nullable: false), - StartAir = table.Column(type: "TEXT", nullable: true), - EndAir = table.Column(type: "TEXT", nullable: true), - Images = table.Column(type: "TEXT", nullable: true), - IsMovie = table.Column(type: "INTEGER", nullable: false), - StudioID = table.Column(type: "INTEGER", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Shows", x => x.ID); - table.ForeignKey( - name: "FK_Shows_Studios_StudioID", - column: x => x.StudioID, - principalTable: "Studios", - principalColumn: "ID", - onDelete: ReferentialAction.SetNull); - }); - - migrationBuilder.CreateTable( - name: "StudioMetadataID", - columns: table => new - { - ResourceID = table.Column(type: "INTEGER", nullable: false), - ProviderID = table.Column(type: "INTEGER", nullable: false), - DataID = table.Column(type: "TEXT", nullable: true), - Link = table.Column(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_StudioMetadataID", x => new { x.ResourceID, x.ProviderID }); - table.ForeignKey( - name: "FK_StudioMetadataID_Providers_ProviderID", - column: x => x.ProviderID, - principalTable: "Providers", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_StudioMetadataID_Studios_ResourceID", - column: x => x.ResourceID, - principalTable: "Studios", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "LinkCollectionShow", - columns: table => new - { - CollectionID = table.Column(type: "INTEGER", nullable: false), - ShowID = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_LinkCollectionShow", x => new { x.CollectionID, x.ShowID }); - table.ForeignKey( - name: "FK_LinkCollectionShow_Collections_CollectionID", - column: x => x.CollectionID, - principalTable: "Collections", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_LinkCollectionShow_Shows_ShowID", - column: x => x.ShowID, - principalTable: "Shows", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "LinkLibraryShow", - columns: table => new - { - LibraryID = table.Column(type: "INTEGER", nullable: false), - ShowID = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_LinkLibraryShow", x => new { x.LibraryID, x.ShowID }); - table.ForeignKey( - name: "FK_LinkLibraryShow_Libraries_LibraryID", - column: x => x.LibraryID, - principalTable: "Libraries", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_LinkLibraryShow_Shows_ShowID", - column: x => x.ShowID, - principalTable: "Shows", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "LinkShowGenre", - columns: table => new - { - GenreID = table.Column(type: "INTEGER", nullable: false), - ShowID = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_LinkShowGenre", x => new { x.GenreID, x.ShowID }); - table.ForeignKey( - name: "FK_LinkShowGenre_Genres_GenreID", - column: x => x.GenreID, - principalTable: "Genres", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_LinkShowGenre_Shows_ShowID", - column: x => x.ShowID, - principalTable: "Shows", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "LinkUserShow", - columns: table => new - { - UsersID = table.Column(type: "INTEGER", nullable: false), - WatchedID = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_LinkUserShow", x => new { x.UsersID, x.WatchedID }); - table.ForeignKey( - name: "FK_LinkUserShow_Shows_WatchedID", - column: x => x.WatchedID, - principalTable: "Shows", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_LinkUserShow_Users_UsersID", - column: x => x.UsersID, - principalTable: "Users", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "PeopleRoles", - columns: table => new - { - ID = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - PeopleID = table.Column(type: "INTEGER", nullable: false), - ShowID = table.Column(type: "INTEGER", nullable: false), - Type = table.Column(type: "TEXT", nullable: true), - Role = table.Column(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_PeopleRoles", x => x.ID); - table.ForeignKey( - name: "FK_PeopleRoles_People_PeopleID", - column: x => x.PeopleID, - principalTable: "People", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_PeopleRoles_Shows_ShowID", - column: x => x.ShowID, - principalTable: "Shows", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Seasons", - columns: table => new - { - ID = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Slug = table.Column(type: "TEXT", nullable: true), - ShowID = table.Column(type: "INTEGER", nullable: false), - SeasonNumber = table.Column(type: "INTEGER", nullable: false), - Title = table.Column(type: "TEXT", nullable: true), - Overview = table.Column(type: "TEXT", nullable: true), - StartDate = table.Column(type: "TEXT", nullable: true), - EndDate = table.Column(type: "TEXT", nullable: true), - Images = table.Column(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Seasons", x => x.ID); - table.ForeignKey( - name: "FK_Seasons_Shows_ShowID", - column: x => x.ShowID, - principalTable: "Shows", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "ShowMetadataID", - columns: table => new - { - ResourceID = table.Column(type: "INTEGER", nullable: false), - ProviderID = table.Column(type: "INTEGER", nullable: false), - DataID = table.Column(type: "TEXT", nullable: true), - Link = table.Column(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_ShowMetadataID", x => new { x.ResourceID, x.ProviderID }); - table.ForeignKey( - name: "FK_ShowMetadataID_Providers_ProviderID", - column: x => x.ProviderID, - principalTable: "Providers", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_ShowMetadataID_Shows_ResourceID", - column: x => x.ResourceID, - principalTable: "Shows", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Episodes", - columns: table => new - { - ID = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Slug = table.Column(type: "TEXT", nullable: true), - ShowID = table.Column(type: "INTEGER", nullable: false), - SeasonID = table.Column(type: "INTEGER", nullable: true), - SeasonNumber = table.Column(type: "INTEGER", nullable: true), - EpisodeNumber = table.Column(type: "INTEGER", nullable: true), - AbsoluteNumber = table.Column(type: "INTEGER", nullable: true), - Path = table.Column(type: "TEXT", nullable: true), - Images = table.Column(type: "TEXT", nullable: true), - Title = table.Column(type: "TEXT", nullable: true), - Overview = table.Column(type: "TEXT", nullable: true), - ReleaseDate = table.Column(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Episodes", x => x.ID); - table.ForeignKey( - name: "FK_Episodes_Seasons_SeasonID", - column: x => x.SeasonID, - principalTable: "Seasons", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Episodes_Shows_ShowID", - column: x => x.ShowID, - principalTable: "Shows", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "SeasonMetadataID", - columns: table => new - { - ResourceID = table.Column(type: "INTEGER", nullable: false), - ProviderID = table.Column(type: "INTEGER", nullable: false), - DataID = table.Column(type: "TEXT", nullable: true), - Link = table.Column(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_SeasonMetadataID", x => new { x.ResourceID, x.ProviderID }); - table.ForeignKey( - name: "FK_SeasonMetadataID_Providers_ProviderID", - column: x => x.ProviderID, - principalTable: "Providers", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_SeasonMetadataID_Seasons_ResourceID", - column: x => x.ResourceID, - principalTable: "Seasons", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "EpisodeMetadataID", - columns: table => new - { - ResourceID = table.Column(type: "INTEGER", nullable: false), - ProviderID = table.Column(type: "INTEGER", nullable: false), - DataID = table.Column(type: "TEXT", nullable: true), - Link = table.Column(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_EpisodeMetadataID", x => new { x.ResourceID, x.ProviderID }); - table.ForeignKey( - name: "FK_EpisodeMetadataID_Episodes_ResourceID", - column: x => x.ResourceID, - principalTable: "Episodes", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_EpisodeMetadataID_Providers_ProviderID", - column: x => x.ProviderID, - principalTable: "Providers", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Tracks", - columns: table => new - { - ID = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Slug = table.Column(type: "TEXT", nullable: true), - Title = table.Column(type: "TEXT", nullable: true), - Language = table.Column(type: "TEXT", nullable: true), - Codec = table.Column(type: "TEXT", nullable: true), - IsDefault = table.Column(type: "INTEGER", nullable: false), - IsForced = table.Column(type: "INTEGER", nullable: false), - IsExternal = table.Column(type: "INTEGER", nullable: false), - Path = table.Column(type: "TEXT", nullable: true), - Type = table.Column(type: "INTEGER", nullable: false), - EpisodeID = table.Column(type: "INTEGER", nullable: false), - TrackIndex = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Tracks", x => x.ID); - table.ForeignKey( - name: "FK_Tracks_Episodes_EpisodeID", - column: x => x.EpisodeID, - principalTable: "Episodes", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "WatchedEpisodes", - columns: table => new - { - UserID = table.Column(type: "INTEGER", nullable: false), - EpisodeID = table.Column(type: "INTEGER", nullable: false), - WatchedPercentage = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_WatchedEpisodes", x => new { x.UserID, x.EpisodeID }); - table.ForeignKey( - name: "FK_WatchedEpisodes_Episodes_EpisodeID", - column: x => x.EpisodeID, - principalTable: "Episodes", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_WatchedEpisodes_Users_UserID", - column: x => x.UserID, - principalTable: "Users", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_CollectionMetadataID_ProviderID", - table: "CollectionMetadataID", - column: "ProviderID"); - - migrationBuilder.CreateIndex( - name: "IX_Collections_Slug", - table: "Collections", - column: "Slug", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_EpisodeMetadataID_ProviderID", - table: "EpisodeMetadataID", - column: "ProviderID"); - - migrationBuilder.CreateIndex( - name: "IX_Episodes_SeasonID", - table: "Episodes", - column: "SeasonID"); - - migrationBuilder.CreateIndex( - name: "IX_Episodes_ShowID_SeasonNumber_EpisodeNumber_AbsoluteNumber", - table: "Episodes", - columns: new[] { "ShowID", "SeasonNumber", "EpisodeNumber", "AbsoluteNumber" }, - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_Episodes_Slug", - table: "Episodes", - column: "Slug", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_Genres_Slug", - table: "Genres", - column: "Slug", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_Libraries_Slug", - table: "Libraries", - column: "Slug", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_LinkCollectionShow_ShowID", - table: "LinkCollectionShow", - column: "ShowID"); - - migrationBuilder.CreateIndex( - name: "IX_LinkLibraryCollection_LibraryID", - table: "LinkLibraryCollection", - column: "LibraryID"); - - migrationBuilder.CreateIndex( - name: "IX_LinkLibraryProvider_ProviderID", - table: "LinkLibraryProvider", - column: "ProviderID"); - - migrationBuilder.CreateIndex( - name: "IX_LinkLibraryShow_ShowID", - table: "LinkLibraryShow", - column: "ShowID"); - - migrationBuilder.CreateIndex( - name: "IX_LinkShowGenre_ShowID", - table: "LinkShowGenre", - column: "ShowID"); - - migrationBuilder.CreateIndex( - name: "IX_LinkUserShow_WatchedID", - table: "LinkUserShow", - column: "WatchedID"); - - migrationBuilder.CreateIndex( - name: "IX_People_Slug", - table: "People", - column: "Slug", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_PeopleMetadataID_ProviderID", - table: "PeopleMetadataID", - column: "ProviderID"); - - migrationBuilder.CreateIndex( - name: "IX_PeopleRoles_PeopleID", - table: "PeopleRoles", - column: "PeopleID"); - - migrationBuilder.CreateIndex( - name: "IX_PeopleRoles_ShowID", - table: "PeopleRoles", - column: "ShowID"); - - migrationBuilder.CreateIndex( - name: "IX_Providers_Slug", - table: "Providers", - column: "Slug", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_SeasonMetadataID_ProviderID", - table: "SeasonMetadataID", - column: "ProviderID"); - - migrationBuilder.CreateIndex( - name: "IX_Seasons_ShowID_SeasonNumber", - table: "Seasons", - columns: new[] { "ShowID", "SeasonNumber" }, - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_Seasons_Slug", - table: "Seasons", - column: "Slug", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_ShowMetadataID_ProviderID", - table: "ShowMetadataID", - column: "ProviderID"); - - migrationBuilder.CreateIndex( - name: "IX_Shows_Slug", - table: "Shows", - column: "Slug", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_Shows_StudioID", - table: "Shows", - column: "StudioID"); - - migrationBuilder.CreateIndex( - name: "IX_StudioMetadataID_ProviderID", - table: "StudioMetadataID", - column: "ProviderID"); - - migrationBuilder.CreateIndex( - name: "IX_Studios_Slug", - table: "Studios", - column: "Slug", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_Tracks_EpisodeID_Type_Language_TrackIndex_IsForced", - table: "Tracks", - columns: new[] { "EpisodeID", "Type", "Language", "TrackIndex", "IsForced" }, - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_Tracks_Slug", - table: "Tracks", - column: "Slug", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_Users_Slug", - table: "Users", - column: "Slug", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_WatchedEpisodes_EpisodeID", - table: "WatchedEpisodes", - column: "EpisodeID"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "CollectionMetadataID"); - - migrationBuilder.DropTable( - name: "EpisodeMetadataID"); - - migrationBuilder.DropTable( - name: "LinkCollectionShow"); - - migrationBuilder.DropTable( - name: "LinkLibraryCollection"); - - migrationBuilder.DropTable( - name: "LinkLibraryProvider"); - - migrationBuilder.DropTable( - name: "LinkLibraryShow"); - - migrationBuilder.DropTable( - name: "LinkShowGenre"); - - migrationBuilder.DropTable( - name: "LinkUserShow"); - - migrationBuilder.DropTable( - name: "PeopleMetadataID"); - - migrationBuilder.DropTable( - name: "PeopleRoles"); - - migrationBuilder.DropTable( - name: "SeasonMetadataID"); - - migrationBuilder.DropTable( - name: "ShowMetadataID"); - - migrationBuilder.DropTable( - name: "StudioMetadataID"); - - migrationBuilder.DropTable( - name: "Tracks"); - - migrationBuilder.DropTable( - name: "WatchedEpisodes"); - - migrationBuilder.DropTable( - name: "Collections"); - - migrationBuilder.DropTable( - name: "Libraries"); - - migrationBuilder.DropTable( - name: "Genres"); - - migrationBuilder.DropTable( - name: "People"); - - migrationBuilder.DropTable( - name: "Providers"); - - migrationBuilder.DropTable( - name: "Episodes"); - - migrationBuilder.DropTable( - name: "Users"); - - migrationBuilder.DropTable( - name: "Seasons"); - - migrationBuilder.DropTable( - name: "Shows"); - - migrationBuilder.DropTable( - name: "Studios"); - } - } -} diff --git a/back/src/Kyoo.SqLite/Migrations/20210801171544_Triggers.Designer.cs b/back/src/Kyoo.SqLite/Migrations/20210801171544_Triggers.Designer.cs deleted file mode 100644 index 1576e9e3..00000000 --- a/back/src/Kyoo.SqLite/Migrations/20210801171544_Triggers.Designer.cs +++ /dev/null @@ -1,1020 +0,0 @@ -// -using System; -using Kyoo.SqLite; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -namespace Kyoo.SqLite.Migrations -{ - [DbContext(typeof(SqLiteContext))] - [Migration("20210801171544_Triggers")] - partial class Triggers - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "5.0.8"); - - modelBuilder.Entity("CollectionMetadataID", b => - { - b.Property("ResourceID") - .HasColumnType("INTEGER"); - - b.Property("ProviderID") - .HasColumnType("INTEGER"); - - b.Property("DataID") - .HasColumnType("TEXT"); - - b.Property("Link") - .HasColumnType("TEXT"); - - b.HasKey("ResourceID", "ProviderID"); - - b.HasIndex("ProviderID"); - - b.ToTable("CollectionMetadataID"); - }); - - modelBuilder.Entity("EpisodeMetadataID", b => - { - b.Property("ResourceID") - .HasColumnType("INTEGER"); - - b.Property("ProviderID") - .HasColumnType("INTEGER"); - - b.Property("DataID") - .HasColumnType("TEXT"); - - b.Property("Link") - .HasColumnType("TEXT"); - - b.HasKey("ResourceID", "ProviderID"); - - b.HasIndex("ProviderID"); - - b.ToTable("EpisodeMetadataID"); - }); - - modelBuilder.Entity("Kyoo.Models.Collection", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Images") - .HasColumnType("TEXT"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Overview") - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.ToTable("Collections"); - }); - - modelBuilder.Entity("Kyoo.Models.Episode", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("AbsoluteNumber") - .HasColumnType("INTEGER"); - - b.Property("EpisodeNumber") - .HasColumnType("INTEGER"); - - b.Property("Images") - .HasColumnType("TEXT"); - - b.Property("Overview") - .HasColumnType("TEXT"); - - b.Property("Path") - .HasColumnType("TEXT"); - - b.Property("ReleaseDate") - .HasColumnType("TEXT"); - - b.Property("SeasonID") - .HasColumnType("INTEGER"); - - b.Property("SeasonNumber") - .HasColumnType("INTEGER"); - - b.Property("ShowID") - .HasColumnType("INTEGER"); - - b.Property("Slug") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TEXT"); - - b.Property("Title") - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("SeasonID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.HasIndex("ShowID", "SeasonNumber", "EpisodeNumber", "AbsoluteNumber") - .IsUnique(); - - b.ToTable("Episodes"); - }); - - modelBuilder.Entity("Kyoo.Models.Genre", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.ToTable("Genres"); - }); - - modelBuilder.Entity("Kyoo.Models.Library", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Paths") - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.ToTable("Libraries"); - }); - - modelBuilder.Entity("Kyoo.Models.LibraryItem", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("EndAir") - .HasColumnType("TEXT"); - - b.Property("Images") - .HasColumnType("TEXT"); - - b.Property("Overview") - .HasColumnType("TEXT"); - - b.Property("Slug") - .HasColumnType("TEXT"); - - b.Property("StartAir") - .HasColumnType("TEXT"); - - b.Property("Status") - .HasColumnType("INTEGER"); - - b.Property("Title") - .HasColumnType("TEXT"); - - b.Property("Type") - .HasColumnType("INTEGER"); - - b.HasKey("ID"); - - b.ToView("LibraryItems"); - }); - - modelBuilder.Entity("Kyoo.Models.People", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Images") - .HasColumnType("TEXT"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.ToTable("People"); - }); - - modelBuilder.Entity("Kyoo.Models.PeopleRole", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("PeopleID") - .HasColumnType("INTEGER"); - - b.Property("Role") - .HasColumnType("TEXT"); - - b.Property("ShowID") - .HasColumnType("INTEGER"); - - b.Property("Type") - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("PeopleID"); - - b.HasIndex("ShowID"); - - b.ToTable("PeopleRoles"); - }); - - modelBuilder.Entity("Kyoo.Models.Provider", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Images") - .HasColumnType("TEXT"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.ToTable("Providers"); - }); - - modelBuilder.Entity("Kyoo.Models.Season", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("EndDate") - .HasColumnType("TEXT"); - - b.Property("Images") - .HasColumnType("TEXT"); - - b.Property("Overview") - .HasColumnType("TEXT"); - - b.Property("SeasonNumber") - .HasColumnType("INTEGER"); - - b.Property("ShowID") - .HasColumnType("INTEGER"); - - b.Property("Slug") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TEXT"); - - b.Property("StartDate") - .HasColumnType("TEXT"); - - b.Property("Title") - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.HasIndex("ShowID", "SeasonNumber") - .IsUnique(); - - b.ToTable("Seasons"); - }); - - modelBuilder.Entity("Kyoo.Models.Show", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Aliases") - .HasColumnType("TEXT"); - - b.Property("EndAir") - .HasColumnType("TEXT"); - - b.Property("Images") - .HasColumnType("TEXT"); - - b.Property("IsMovie") - .HasColumnType("INTEGER"); - - b.Property("Overview") - .HasColumnType("TEXT"); - - b.Property("Path") - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("StartAir") - .HasColumnType("TEXT"); - - b.Property("Status") - .HasColumnType("INTEGER"); - - b.Property("StudioID") - .HasColumnType("INTEGER"); - - b.Property("Title") - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.HasIndex("StudioID"); - - b.ToTable("Shows"); - }); - - modelBuilder.Entity("Kyoo.Models.Studio", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.ToTable("Studios"); - }); - - modelBuilder.Entity("Kyoo.Models.Track", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Codec") - .HasColumnType("TEXT"); - - b.Property("EpisodeID") - .HasColumnType("INTEGER"); - - b.Property("IsDefault") - .HasColumnType("INTEGER"); - - b.Property("IsExternal") - .HasColumnType("INTEGER"); - - b.Property("IsForced") - .HasColumnType("INTEGER"); - - b.Property("Language") - .HasColumnType("TEXT"); - - b.Property("Path") - .HasColumnType("TEXT"); - - b.Property("Slug") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TEXT"); - - b.Property("Title") - .HasColumnType("TEXT"); - - b.Property("TrackIndex") - .HasColumnType("INTEGER"); - - b.Property("Type") - .HasColumnType("INTEGER"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.HasIndex("EpisodeID", "Type", "Language", "TrackIndex", "IsForced") - .IsUnique(); - - b.ToTable("Tracks"); - }); - - modelBuilder.Entity("Kyoo.Models.User", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Email") - .HasColumnType("TEXT"); - - b.Property("ExtraData") - .HasColumnType("TEXT"); - - b.Property("Images") - .HasColumnType("TEXT"); - - b.Property("Password") - .HasColumnType("TEXT"); - - b.Property("Permissions") - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Username") - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Kyoo.Models.WatchedEpisode", b => - { - b.Property("UserID") - .HasColumnType("INTEGER"); - - b.Property("EpisodeID") - .HasColumnType("INTEGER"); - - b.Property("WatchedPercentage") - .HasColumnType("INTEGER"); - - b.HasKey("UserID", "EpisodeID"); - - b.HasIndex("EpisodeID"); - - b.ToTable("WatchedEpisodes"); - }); - - modelBuilder.Entity("LinkCollectionShow", b => - { - b.Property("CollectionID") - .HasColumnType("INTEGER"); - - b.Property("ShowID") - .HasColumnType("INTEGER"); - - b.HasKey("CollectionID", "ShowID"); - - b.HasIndex("ShowID"); - - b.ToTable("LinkCollectionShow"); - }); - - modelBuilder.Entity("LinkLibraryCollection", b => - { - b.Property("CollectionID") - .HasColumnType("INTEGER"); - - b.Property("LibraryID") - .HasColumnType("INTEGER"); - - b.HasKey("CollectionID", "LibraryID"); - - b.HasIndex("LibraryID"); - - b.ToTable("LinkLibraryCollection"); - }); - - modelBuilder.Entity("LinkLibraryProvider", b => - { - b.Property("LibraryID") - .HasColumnType("INTEGER"); - - b.Property("ProviderID") - .HasColumnType("INTEGER"); - - b.HasKey("LibraryID", "ProviderID"); - - b.HasIndex("ProviderID"); - - b.ToTable("LinkLibraryProvider"); - }); - - modelBuilder.Entity("LinkLibraryShow", b => - { - b.Property("LibraryID") - .HasColumnType("INTEGER"); - - b.Property("ShowID") - .HasColumnType("INTEGER"); - - b.HasKey("LibraryID", "ShowID"); - - b.HasIndex("ShowID"); - - b.ToTable("LinkLibraryShow"); - }); - - modelBuilder.Entity("LinkShowGenre", b => - { - b.Property("GenreID") - .HasColumnType("INTEGER"); - - b.Property("ShowID") - .HasColumnType("INTEGER"); - - b.HasKey("GenreID", "ShowID"); - - b.HasIndex("ShowID"); - - b.ToTable("LinkShowGenre"); - }); - - modelBuilder.Entity("PeopleMetadataID", b => - { - b.Property("ResourceID") - .HasColumnType("INTEGER"); - - b.Property("ProviderID") - .HasColumnType("INTEGER"); - - b.Property("DataID") - .HasColumnType("TEXT"); - - b.Property("Link") - .HasColumnType("TEXT"); - - b.HasKey("ResourceID", "ProviderID"); - - b.HasIndex("ProviderID"); - - b.ToTable("PeopleMetadataID"); - }); - - modelBuilder.Entity("SeasonMetadataID", b => - { - b.Property("ResourceID") - .HasColumnType("INTEGER"); - - b.Property("ProviderID") - .HasColumnType("INTEGER"); - - b.Property("DataID") - .HasColumnType("TEXT"); - - b.Property("Link") - .HasColumnType("TEXT"); - - b.HasKey("ResourceID", "ProviderID"); - - b.HasIndex("ProviderID"); - - b.ToTable("SeasonMetadataID"); - }); - - modelBuilder.Entity("ShowMetadataID", b => - { - b.Property("ResourceID") - .HasColumnType("INTEGER"); - - b.Property("ProviderID") - .HasColumnType("INTEGER"); - - b.Property("DataID") - .HasColumnType("TEXT"); - - b.Property("Link") - .HasColumnType("TEXT"); - - b.HasKey("ResourceID", "ProviderID"); - - b.HasIndex("ProviderID"); - - b.ToTable("ShowMetadataID"); - }); - - modelBuilder.Entity("ShowUser", b => - { - b.Property("UsersID") - .HasColumnType("INTEGER"); - - b.Property("WatchedID") - .HasColumnType("INTEGER"); - - b.HasKey("UsersID", "WatchedID"); - - b.HasIndex("WatchedID"); - - b.ToTable("LinkUserShow"); - }); - - modelBuilder.Entity("StudioMetadataID", b => - { - b.Property("ResourceID") - .HasColumnType("INTEGER"); - - b.Property("ProviderID") - .HasColumnType("INTEGER"); - - b.Property("DataID") - .HasColumnType("TEXT"); - - b.Property("Link") - .HasColumnType("TEXT"); - - b.HasKey("ResourceID", "ProviderID"); - - b.HasIndex("ProviderID"); - - b.ToTable("StudioMetadataID"); - }); - - modelBuilder.Entity("CollectionMetadataID", b => - { - b.HasOne("Kyoo.Models.Provider", "Provider") - .WithMany() - .HasForeignKey("ProviderID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Collection", null) - .WithMany("ExternalIDs") - .HasForeignKey("ResourceID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Provider"); - }); - - modelBuilder.Entity("EpisodeMetadataID", b => - { - b.HasOne("Kyoo.Models.Provider", "Provider") - .WithMany() - .HasForeignKey("ProviderID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Episode", null) - .WithMany("ExternalIDs") - .HasForeignKey("ResourceID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Provider"); - }); - - modelBuilder.Entity("Kyoo.Models.Episode", b => - { - b.HasOne("Kyoo.Models.Season", "Season") - .WithMany("Episodes") - .HasForeignKey("SeasonID") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("Kyoo.Models.Show", "Show") - .WithMany("Episodes") - .HasForeignKey("ShowID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Season"); - - b.Navigation("Show"); - }); - - modelBuilder.Entity("Kyoo.Models.PeopleRole", b => - { - b.HasOne("Kyoo.Models.People", "People") - .WithMany("Roles") - .HasForeignKey("PeopleID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Show", "Show") - .WithMany("People") - .HasForeignKey("ShowID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("People"); - - b.Navigation("Show"); - }); - - modelBuilder.Entity("Kyoo.Models.Season", b => - { - b.HasOne("Kyoo.Models.Show", "Show") - .WithMany("Seasons") - .HasForeignKey("ShowID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Show"); - }); - - modelBuilder.Entity("Kyoo.Models.Show", b => - { - b.HasOne("Kyoo.Models.Studio", "Studio") - .WithMany("Shows") - .HasForeignKey("StudioID") - .OnDelete(DeleteBehavior.SetNull); - - b.Navigation("Studio"); - }); - - modelBuilder.Entity("Kyoo.Models.Track", b => - { - b.HasOne("Kyoo.Models.Episode", "Episode") - .WithMany("Tracks") - .HasForeignKey("EpisodeID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Episode"); - }); - - modelBuilder.Entity("Kyoo.Models.WatchedEpisode", b => - { - b.HasOne("Kyoo.Models.Episode", "Episode") - .WithMany() - .HasForeignKey("EpisodeID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.User", null) - .WithMany("CurrentlyWatching") - .HasForeignKey("UserID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Episode"); - }); - - modelBuilder.Entity("LinkCollectionShow", b => - { - b.HasOne("Kyoo.Models.Collection", null) - .WithMany() - .HasForeignKey("CollectionID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Show", null) - .WithMany() - .HasForeignKey("ShowID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("LinkLibraryCollection", b => - { - b.HasOne("Kyoo.Models.Collection", null) - .WithMany() - .HasForeignKey("CollectionID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Library", null) - .WithMany() - .HasForeignKey("LibraryID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("LinkLibraryProvider", b => - { - b.HasOne("Kyoo.Models.Library", null) - .WithMany() - .HasForeignKey("LibraryID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Provider", null) - .WithMany() - .HasForeignKey("ProviderID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("LinkLibraryShow", b => - { - b.HasOne("Kyoo.Models.Library", null) - .WithMany() - .HasForeignKey("LibraryID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Show", null) - .WithMany() - .HasForeignKey("ShowID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("LinkShowGenre", b => - { - b.HasOne("Kyoo.Models.Genre", null) - .WithMany() - .HasForeignKey("GenreID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Show", null) - .WithMany() - .HasForeignKey("ShowID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("PeopleMetadataID", b => - { - b.HasOne("Kyoo.Models.Provider", "Provider") - .WithMany() - .HasForeignKey("ProviderID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.People", null) - .WithMany("ExternalIDs") - .HasForeignKey("ResourceID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Provider"); - }); - - modelBuilder.Entity("SeasonMetadataID", b => - { - b.HasOne("Kyoo.Models.Provider", "Provider") - .WithMany() - .HasForeignKey("ProviderID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Season", null) - .WithMany("ExternalIDs") - .HasForeignKey("ResourceID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Provider"); - }); - - modelBuilder.Entity("ShowMetadataID", b => - { - b.HasOne("Kyoo.Models.Provider", "Provider") - .WithMany() - .HasForeignKey("ProviderID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Show", null) - .WithMany("ExternalIDs") - .HasForeignKey("ResourceID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Provider"); - }); - - modelBuilder.Entity("ShowUser", b => - { - b.HasOne("Kyoo.Models.User", null) - .WithMany() - .HasForeignKey("UsersID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Show", null) - .WithMany() - .HasForeignKey("WatchedID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("StudioMetadataID", b => - { - b.HasOne("Kyoo.Models.Provider", "Provider") - .WithMany() - .HasForeignKey("ProviderID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Studio", null) - .WithMany("ExternalIDs") - .HasForeignKey("ResourceID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Provider"); - }); - - modelBuilder.Entity("Kyoo.Models.Collection", b => - { - b.Navigation("ExternalIDs"); - }); - - modelBuilder.Entity("Kyoo.Models.Episode", b => - { - b.Navigation("ExternalIDs"); - - b.Navigation("Tracks"); - }); - - modelBuilder.Entity("Kyoo.Models.People", b => - { - b.Navigation("ExternalIDs"); - - b.Navigation("Roles"); - }); - - modelBuilder.Entity("Kyoo.Models.Season", b => - { - b.Navigation("Episodes"); - - b.Navigation("ExternalIDs"); - }); - - modelBuilder.Entity("Kyoo.Models.Show", b => - { - b.Navigation("Episodes"); - - b.Navigation("ExternalIDs"); - - b.Navigation("People"); - - b.Navigation("Seasons"); - }); - - modelBuilder.Entity("Kyoo.Models.Studio", b => - { - b.Navigation("ExternalIDs"); - - b.Navigation("Shows"); - }); - - modelBuilder.Entity("Kyoo.Models.User", b => - { - b.Navigation("CurrentlyWatching"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/back/src/Kyoo.SqLite/Migrations/20210801171544_Triggers.cs b/back/src/Kyoo.SqLite/Migrations/20210801171544_Triggers.cs deleted file mode 100644 index 10f184c7..00000000 --- a/back/src/Kyoo.SqLite/Migrations/20210801171544_Triggers.cs +++ /dev/null @@ -1,208 +0,0 @@ -// 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 . - -using Microsoft.EntityFrameworkCore.Migrations; - -namespace Kyoo.SqLite.Migrations -{ - /// - /// A migration that adds sqlite triggers to update slugs. - /// - public partial class Triggers : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - // language=SQLite - migrationBuilder.Sql(@" - CREATE TRIGGER SeasonSlugInsert AFTER INSERT ON Seasons FOR EACH ROW - BEGIN - UPDATE Seasons SET Slug = (SELECT Slug from Shows WHERE ID = ShowID) || '-s' || SeasonNumber - WHERE ID == new.ID; - END"); - // language=SQLite - migrationBuilder.Sql(@" - CREATE TRIGGER SeasonSlugUpdate AFTER UPDATE OF SeasonNumber, ShowID ON Seasons FOR EACH ROW - BEGIN - UPDATE Seasons SET Slug = (SELECT Slug from Shows WHERE ID = ShowID) || '-s' || SeasonNumber - WHERE ID == new.ID; - END"); - - // language=SQLite - migrationBuilder.Sql(@" - CREATE TRIGGER EpisodeSlugInsert AFTER INSERT ON Episodes FOR EACH ROW - BEGIN - UPDATE Episodes - SET Slug = (SELECT Slug from Shows WHERE ID = ShowID) || - CASE - WHEN SeasonNumber IS NULL AND AbsoluteNumber IS NULL THEN '' - WHEN SeasonNumber IS NULL THEN '-' || AbsoluteNumber - ELSE '-s' || SeasonNumber || 'e' || EpisodeNumber - END - WHERE ID == new.ID; - END"); - // language=SQLite - migrationBuilder.Sql(@" - CREATE TRIGGER EpisodeSlugUpdate AFTER UPDATE OF AbsoluteNumber, EpisodeNumber, SeasonNumber, ShowID - ON Episodes FOR EACH ROW - BEGIN - UPDATE Episodes - SET Slug = (SELECT Slug from Shows WHERE ID = ShowID) || - CASE - WHEN SeasonNumber IS NULL AND AbsoluteNumber IS NULL THEN '' - WHEN SeasonNumber IS NULL THEN '-' || AbsoluteNumber - ELSE '-s' || SeasonNumber || 'e' || EpisodeNumber - END - WHERE ID == new.ID; - END"); - - // language=SQLite - migrationBuilder.Sql(@" - CREATE TRIGGER TrackSlugInsert - AFTER INSERT ON Tracks - FOR EACH ROW - BEGIN - UPDATE Tracks SET TrackIndex = ( - SELECT COUNT(*) FROM Tracks - WHERE EpisodeID = new.EpisodeID AND Type = new.Type - AND Language = new.Language AND IsForced = new.IsForced - ) WHERE ID = new.ID AND TrackIndex = 0; - UPDATE Tracks SET Slug = (SELECT Slug FROM Episodes WHERE ID = EpisodeID) || - '.' || COALESCE(Language, 'und') || - CASE (TrackIndex) - WHEN 0 THEN '' - ELSE '-' || (TrackIndex) - END || - CASE (IsForced) - WHEN false THEN '' - ELSE '.forced' - END || - CASE (Type) - WHEN 1 THEN '.video' - WHEN 2 THEN '.audio' - WHEN 3 THEN '.subtitle' - ELSE '.' || Type - END - WHERE ID = new.ID; - END;"); - // language=SQLite - migrationBuilder.Sql(@" - CREATE TRIGGER TrackSlugUpdate - AFTER UPDATE OF EpisodeID, IsForced, Language, TrackIndex, Type ON Tracks - FOR EACH ROW - BEGIN - UPDATE Tracks SET TrackIndex = ( - SELECT COUNT(*) FROM Tracks - WHERE EpisodeID = new.EpisodeID AND Type = new.Type - AND Language = new.Language AND IsForced = new.IsForced - ) WHERE ID = new.ID AND TrackIndex = 0; - UPDATE Tracks SET Slug = - (SELECT Slug FROM Episodes WHERE ID = EpisodeID) || - '.' || Language || - CASE (TrackIndex) - WHEN 0 THEN '' - ELSE '-' || (TrackIndex) - END || - CASE (IsForced) - WHEN false THEN '' - ELSE '.forced' - END || - CASE (Type) - WHEN 1 THEN '.video' - WHEN 2 THEN '.audio' - WHEN 3 THEN '.subtitle' - ELSE '.' || Type - END - WHERE ID = new.ID; - END;"); - // language=SQLite - migrationBuilder.Sql(@" - CREATE TRIGGER EpisodeUpdateTracksSlug - AFTER UPDATE OF Slug ON Episodes - FOR EACH ROW - BEGIN - UPDATE Tracks SET Slug = - NEW.Slug || - '.' || Language || - CASE (TrackIndex) - WHEN 0 THEN '' - ELSE '-' || TrackIndex - END || - CASE (IsForced) - WHEN false THEN '' - ELSE '.forced' - END || - CASE (Type) - WHEN 1 THEN '.video' - WHEN 2 THEN '.audio' - WHEN 3 THEN '.subtitle' - ELSE '.' || Type - END - WHERE EpisodeID = NEW.ID; - END;"); - - // language=SQLite - migrationBuilder.Sql(@" - CREATE TRIGGER ShowSlugUpdate AFTER UPDATE OF Slug ON Shows FOR EACH ROW - BEGIN - UPDATE Seasons SET Slug = new.Slug || '-s' || SeasonNumber WHERE ShowID = new.ID; - UPDATE Episodes - SET Slug = new.Slug || - CASE - WHEN SeasonNumber IS NULL AND AbsoluteNumber IS NULL THEN '' - WHEN SeasonNumber IS NULL THEN '-' || AbsoluteNumber - ELSE '-s' || SeasonNumber || 'e' || EpisodeNumber - END - WHERE ShowID = new.ID; - END;"); - - // language=SQLite - migrationBuilder.Sql(@" - CREATE VIEW LibraryItems AS - SELECT s.ID, s.Slug, s.Title, s.Overview, s.Status, s.StartAir, s.EndAir, s.Images, CASE - WHEN s.IsMovie THEN 1 - ELSE 0 - END AS Type - FROM Shows AS s - WHERE NOT (EXISTS ( - SELECT 1 - FROM LinkCollectionShow AS l - INNER JOIN Collections AS c ON l.CollectionID = c.ID - WHERE s.ID = l.ShowID)) - UNION ALL - SELECT -c0.ID, c0.Slug, c0.Name AS Title, c0.Overview, 0 AS Status, - NULL AS StartAir, NULL AS EndAir, c0.Images, 2 AS Type - FROM collections AS c0"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - // language=SQLite - migrationBuilder.Sql("DROP TRIGGER SeasonSlugInsert;"); - // language=SQLite - migrationBuilder.Sql("DROP TRIGGER SeasonSlugUpdate;"); - // language=SQLite - migrationBuilder.Sql("DROP TRIGGER EpisodeSlugInsert;"); - // language=SQLite - migrationBuilder.Sql("DROP TRIGGER EpisodeSlugUpdate;"); - // language=SQLite - migrationBuilder.Sql("DROP TRIGGER ShowSlugUpdate;"); - } - } -} diff --git a/back/src/Kyoo.SqLite/Migrations/SqLiteContextModelSnapshot.cs b/back/src/Kyoo.SqLite/Migrations/SqLiteContextModelSnapshot.cs deleted file mode 100644 index c70f4f42..00000000 --- a/back/src/Kyoo.SqLite/Migrations/SqLiteContextModelSnapshot.cs +++ /dev/null @@ -1,1017 +0,0 @@ -// -using System; -using Kyoo.SqLite; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -namespace Kyoo.SqLite.Migrations -{ - [DbContext(typeof(SqLiteContext))] - partial class SqLiteContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "5.0.8"); - - modelBuilder.Entity("CollectionMetadataID", b => - { - b.Property("ResourceID") - .HasColumnType("INTEGER"); - - b.Property("ProviderID") - .HasColumnType("INTEGER"); - - b.Property("DataID") - .HasColumnType("TEXT"); - - b.Property("Link") - .HasColumnType("TEXT"); - - b.HasKey("ResourceID", "ProviderID"); - - b.HasIndex("ProviderID"); - - b.ToTable("CollectionMetadataID"); - }); - - modelBuilder.Entity("EpisodeMetadataID", b => - { - b.Property("ResourceID") - .HasColumnType("INTEGER"); - - b.Property("ProviderID") - .HasColumnType("INTEGER"); - - b.Property("DataID") - .HasColumnType("TEXT"); - - b.Property("Link") - .HasColumnType("TEXT"); - - b.HasKey("ResourceID", "ProviderID"); - - b.HasIndex("ProviderID"); - - b.ToTable("EpisodeMetadataID"); - }); - - modelBuilder.Entity("Kyoo.Models.Collection", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Images") - .HasColumnType("TEXT"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Overview") - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.ToTable("Collections"); - }); - - modelBuilder.Entity("Kyoo.Models.Episode", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("AbsoluteNumber") - .HasColumnType("INTEGER"); - - b.Property("EpisodeNumber") - .HasColumnType("INTEGER"); - - b.Property("Images") - .HasColumnType("TEXT"); - - b.Property("Overview") - .HasColumnType("TEXT"); - - b.Property("Path") - .HasColumnType("TEXT"); - - b.Property("ReleaseDate") - .HasColumnType("TEXT"); - - b.Property("SeasonID") - .HasColumnType("INTEGER"); - - b.Property("SeasonNumber") - .HasColumnType("INTEGER"); - - b.Property("ShowID") - .HasColumnType("INTEGER"); - - b.Property("Slug") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TEXT"); - - b.Property("Title") - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("SeasonID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.HasIndex("ShowID", "SeasonNumber", "EpisodeNumber", "AbsoluteNumber") - .IsUnique(); - - b.ToTable("Episodes"); - }); - - modelBuilder.Entity("Kyoo.Models.Genre", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.ToTable("Genres"); - }); - - modelBuilder.Entity("Kyoo.Models.Library", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Paths") - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.ToTable("Libraries"); - }); - - modelBuilder.Entity("Kyoo.Models.LibraryItem", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("EndAir") - .HasColumnType("TEXT"); - - b.Property("Images") - .HasColumnType("TEXT"); - - b.Property("Overview") - .HasColumnType("TEXT"); - - b.Property("Slug") - .HasColumnType("TEXT"); - - b.Property("StartAir") - .HasColumnType("TEXT"); - - b.Property("Status") - .HasColumnType("INTEGER"); - - b.Property("Title") - .HasColumnType("TEXT"); - - b.Property("Type") - .HasColumnType("INTEGER"); - - b.HasKey("ID"); - - b.ToView("LibraryItems"); - }); - - modelBuilder.Entity("Kyoo.Models.People", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Images") - .HasColumnType("TEXT"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.ToTable("People"); - }); - - modelBuilder.Entity("Kyoo.Models.PeopleRole", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("PeopleID") - .HasColumnType("INTEGER"); - - b.Property("Role") - .HasColumnType("TEXT"); - - b.Property("ShowID") - .HasColumnType("INTEGER"); - - b.Property("Type") - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("PeopleID"); - - b.HasIndex("ShowID"); - - b.ToTable("PeopleRoles"); - }); - - modelBuilder.Entity("Kyoo.Models.Provider", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Images") - .HasColumnType("TEXT"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.ToTable("Providers"); - }); - - modelBuilder.Entity("Kyoo.Models.Season", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("EndDate") - .HasColumnType("TEXT"); - - b.Property("Images") - .HasColumnType("TEXT"); - - b.Property("Overview") - .HasColumnType("TEXT"); - - b.Property("SeasonNumber") - .HasColumnType("INTEGER"); - - b.Property("ShowID") - .HasColumnType("INTEGER"); - - b.Property("Slug") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TEXT"); - - b.Property("StartDate") - .HasColumnType("TEXT"); - - b.Property("Title") - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.HasIndex("ShowID", "SeasonNumber") - .IsUnique(); - - b.ToTable("Seasons"); - }); - - modelBuilder.Entity("Kyoo.Models.Show", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Aliases") - .HasColumnType("TEXT"); - - b.Property("EndAir") - .HasColumnType("TEXT"); - - b.Property("Images") - .HasColumnType("TEXT"); - - b.Property("IsMovie") - .HasColumnType("INTEGER"); - - b.Property("Overview") - .HasColumnType("TEXT"); - - b.Property("Path") - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("StartAir") - .HasColumnType("TEXT"); - - b.Property("Status") - .HasColumnType("INTEGER"); - - b.Property("StudioID") - .HasColumnType("INTEGER"); - - b.Property("Title") - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.HasIndex("StudioID"); - - b.ToTable("Shows"); - }); - - modelBuilder.Entity("Kyoo.Models.Studio", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.ToTable("Studios"); - }); - - modelBuilder.Entity("Kyoo.Models.Track", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Codec") - .HasColumnType("TEXT"); - - b.Property("EpisodeID") - .HasColumnType("INTEGER"); - - b.Property("IsDefault") - .HasColumnType("INTEGER"); - - b.Property("IsExternal") - .HasColumnType("INTEGER"); - - b.Property("IsForced") - .HasColumnType("INTEGER"); - - b.Property("Language") - .HasColumnType("TEXT"); - - b.Property("Path") - .HasColumnType("TEXT"); - - b.Property("Slug") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TEXT"); - - b.Property("Title") - .HasColumnType("TEXT"); - - b.Property("TrackIndex") - .HasColumnType("INTEGER"); - - b.Property("Type") - .HasColumnType("INTEGER"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.HasIndex("EpisodeID", "Type", "Language", "TrackIndex", "IsForced") - .IsUnique(); - - b.ToTable("Tracks"); - }); - - modelBuilder.Entity("Kyoo.Models.User", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Email") - .HasColumnType("TEXT"); - - b.Property("ExtraData") - .HasColumnType("TEXT"); - - b.Property("Images") - .HasColumnType("TEXT"); - - b.Property("Password") - .HasColumnType("TEXT"); - - b.Property("Permissions") - .HasColumnType("TEXT"); - - b.Property("Slug") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Username") - .HasColumnType("TEXT"); - - b.HasKey("ID"); - - b.HasIndex("Slug") - .IsUnique(); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Kyoo.Models.WatchedEpisode", b => - { - b.Property("UserID") - .HasColumnType("INTEGER"); - - b.Property("EpisodeID") - .HasColumnType("INTEGER"); - - b.Property("WatchedPercentage") - .HasColumnType("INTEGER"); - - b.HasKey("UserID", "EpisodeID"); - - b.HasIndex("EpisodeID"); - - b.ToTable("WatchedEpisodes"); - }); - - modelBuilder.Entity("LinkCollectionShow", b => - { - b.Property("CollectionID") - .HasColumnType("INTEGER"); - - b.Property("ShowID") - .HasColumnType("INTEGER"); - - b.HasKey("CollectionID", "ShowID"); - - b.HasIndex("ShowID"); - - b.ToTable("LinkCollectionShow"); - }); - - modelBuilder.Entity("LinkLibraryCollection", b => - { - b.Property("CollectionID") - .HasColumnType("INTEGER"); - - b.Property("LibraryID") - .HasColumnType("INTEGER"); - - b.HasKey("CollectionID", "LibraryID"); - - b.HasIndex("LibraryID"); - - b.ToTable("LinkLibraryCollection"); - }); - - modelBuilder.Entity("LinkLibraryProvider", b => - { - b.Property("LibraryID") - .HasColumnType("INTEGER"); - - b.Property("ProviderID") - .HasColumnType("INTEGER"); - - b.HasKey("LibraryID", "ProviderID"); - - b.HasIndex("ProviderID"); - - b.ToTable("LinkLibraryProvider"); - }); - - modelBuilder.Entity("LinkLibraryShow", b => - { - b.Property("LibraryID") - .HasColumnType("INTEGER"); - - b.Property("ShowID") - .HasColumnType("INTEGER"); - - b.HasKey("LibraryID", "ShowID"); - - b.HasIndex("ShowID"); - - b.ToTable("LinkLibraryShow"); - }); - - modelBuilder.Entity("LinkShowGenre", b => - { - b.Property("GenreID") - .HasColumnType("INTEGER"); - - b.Property("ShowID") - .HasColumnType("INTEGER"); - - b.HasKey("GenreID", "ShowID"); - - b.HasIndex("ShowID"); - - b.ToTable("LinkShowGenre"); - }); - - modelBuilder.Entity("PeopleMetadataID", b => - { - b.Property("ResourceID") - .HasColumnType("INTEGER"); - - b.Property("ProviderID") - .HasColumnType("INTEGER"); - - b.Property("DataID") - .HasColumnType("TEXT"); - - b.Property("Link") - .HasColumnType("TEXT"); - - b.HasKey("ResourceID", "ProviderID"); - - b.HasIndex("ProviderID"); - - b.ToTable("PeopleMetadataID"); - }); - - modelBuilder.Entity("SeasonMetadataID", b => - { - b.Property("ResourceID") - .HasColumnType("INTEGER"); - - b.Property("ProviderID") - .HasColumnType("INTEGER"); - - b.Property("DataID") - .HasColumnType("TEXT"); - - b.Property("Link") - .HasColumnType("TEXT"); - - b.HasKey("ResourceID", "ProviderID"); - - b.HasIndex("ProviderID"); - - b.ToTable("SeasonMetadataID"); - }); - - modelBuilder.Entity("ShowMetadataID", b => - { - b.Property("ResourceID") - .HasColumnType("INTEGER"); - - b.Property("ProviderID") - .HasColumnType("INTEGER"); - - b.Property("DataID") - .HasColumnType("TEXT"); - - b.Property("Link") - .HasColumnType("TEXT"); - - b.HasKey("ResourceID", "ProviderID"); - - b.HasIndex("ProviderID"); - - b.ToTable("ShowMetadataID"); - }); - - modelBuilder.Entity("ShowUser", b => - { - b.Property("UsersID") - .HasColumnType("INTEGER"); - - b.Property("WatchedID") - .HasColumnType("INTEGER"); - - b.HasKey("UsersID", "WatchedID"); - - b.HasIndex("WatchedID"); - - b.ToTable("LinkUserShow"); - }); - - modelBuilder.Entity("StudioMetadataID", b => - { - b.Property("ResourceID") - .HasColumnType("INTEGER"); - - b.Property("ProviderID") - .HasColumnType("INTEGER"); - - b.Property("DataID") - .HasColumnType("TEXT"); - - b.Property("Link") - .HasColumnType("TEXT"); - - b.HasKey("ResourceID", "ProviderID"); - - b.HasIndex("ProviderID"); - - b.ToTable("StudioMetadataID"); - }); - - modelBuilder.Entity("CollectionMetadataID", b => - { - b.HasOne("Kyoo.Models.Provider", "Provider") - .WithMany() - .HasForeignKey("ProviderID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Collection", null) - .WithMany("ExternalIDs") - .HasForeignKey("ResourceID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Provider"); - }); - - modelBuilder.Entity("EpisodeMetadataID", b => - { - b.HasOne("Kyoo.Models.Provider", "Provider") - .WithMany() - .HasForeignKey("ProviderID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Episode", null) - .WithMany("ExternalIDs") - .HasForeignKey("ResourceID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Provider"); - }); - - modelBuilder.Entity("Kyoo.Models.Episode", b => - { - b.HasOne("Kyoo.Models.Season", "Season") - .WithMany("Episodes") - .HasForeignKey("SeasonID") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("Kyoo.Models.Show", "Show") - .WithMany("Episodes") - .HasForeignKey("ShowID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Season"); - - b.Navigation("Show"); - }); - - modelBuilder.Entity("Kyoo.Models.PeopleRole", b => - { - b.HasOne("Kyoo.Models.People", "People") - .WithMany("Roles") - .HasForeignKey("PeopleID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Show", "Show") - .WithMany("People") - .HasForeignKey("ShowID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("People"); - - b.Navigation("Show"); - }); - - modelBuilder.Entity("Kyoo.Models.Season", b => - { - b.HasOne("Kyoo.Models.Show", "Show") - .WithMany("Seasons") - .HasForeignKey("ShowID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Show"); - }); - - modelBuilder.Entity("Kyoo.Models.Show", b => - { - b.HasOne("Kyoo.Models.Studio", "Studio") - .WithMany("Shows") - .HasForeignKey("StudioID") - .OnDelete(DeleteBehavior.SetNull); - - b.Navigation("Studio"); - }); - - modelBuilder.Entity("Kyoo.Models.Track", b => - { - b.HasOne("Kyoo.Models.Episode", "Episode") - .WithMany("Tracks") - .HasForeignKey("EpisodeID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Episode"); - }); - - modelBuilder.Entity("Kyoo.Models.WatchedEpisode", b => - { - b.HasOne("Kyoo.Models.Episode", "Episode") - .WithMany() - .HasForeignKey("EpisodeID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.User", null) - .WithMany("CurrentlyWatching") - .HasForeignKey("UserID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Episode"); - }); - - modelBuilder.Entity("LinkCollectionShow", b => - { - b.HasOne("Kyoo.Models.Collection", null) - .WithMany() - .HasForeignKey("CollectionID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Show", null) - .WithMany() - .HasForeignKey("ShowID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("LinkLibraryCollection", b => - { - b.HasOne("Kyoo.Models.Collection", null) - .WithMany() - .HasForeignKey("CollectionID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Library", null) - .WithMany() - .HasForeignKey("LibraryID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("LinkLibraryProvider", b => - { - b.HasOne("Kyoo.Models.Library", null) - .WithMany() - .HasForeignKey("LibraryID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Provider", null) - .WithMany() - .HasForeignKey("ProviderID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("LinkLibraryShow", b => - { - b.HasOne("Kyoo.Models.Library", null) - .WithMany() - .HasForeignKey("LibraryID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Show", null) - .WithMany() - .HasForeignKey("ShowID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("LinkShowGenre", b => - { - b.HasOne("Kyoo.Models.Genre", null) - .WithMany() - .HasForeignKey("GenreID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Show", null) - .WithMany() - .HasForeignKey("ShowID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("PeopleMetadataID", b => - { - b.HasOne("Kyoo.Models.Provider", "Provider") - .WithMany() - .HasForeignKey("ProviderID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.People", null) - .WithMany("ExternalIDs") - .HasForeignKey("ResourceID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Provider"); - }); - - modelBuilder.Entity("SeasonMetadataID", b => - { - b.HasOne("Kyoo.Models.Provider", "Provider") - .WithMany() - .HasForeignKey("ProviderID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Season", null) - .WithMany("ExternalIDs") - .HasForeignKey("ResourceID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Provider"); - }); - - modelBuilder.Entity("ShowMetadataID", b => - { - b.HasOne("Kyoo.Models.Provider", "Provider") - .WithMany() - .HasForeignKey("ProviderID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Show", null) - .WithMany("ExternalIDs") - .HasForeignKey("ResourceID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Provider"); - }); - - modelBuilder.Entity("ShowUser", b => - { - b.HasOne("Kyoo.Models.User", null) - .WithMany() - .HasForeignKey("UsersID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Show", null) - .WithMany() - .HasForeignKey("WatchedID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("StudioMetadataID", b => - { - b.HasOne("Kyoo.Models.Provider", "Provider") - .WithMany() - .HasForeignKey("ProviderID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Kyoo.Models.Studio", null) - .WithMany("ExternalIDs") - .HasForeignKey("ResourceID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Provider"); - }); - - modelBuilder.Entity("Kyoo.Models.Collection", b => - { - b.Navigation("ExternalIDs"); - }); - - modelBuilder.Entity("Kyoo.Models.Episode", b => - { - b.Navigation("ExternalIDs"); - - b.Navigation("Tracks"); - }); - - modelBuilder.Entity("Kyoo.Models.People", b => - { - b.Navigation("ExternalIDs"); - - b.Navigation("Roles"); - }); - - modelBuilder.Entity("Kyoo.Models.Season", b => - { - b.Navigation("Episodes"); - - b.Navigation("ExternalIDs"); - }); - - modelBuilder.Entity("Kyoo.Models.Show", b => - { - b.Navigation("Episodes"); - - b.Navigation("ExternalIDs"); - - b.Navigation("People"); - - b.Navigation("Seasons"); - }); - - modelBuilder.Entity("Kyoo.Models.Studio", b => - { - b.Navigation("ExternalIDs"); - - b.Navigation("Shows"); - }); - - modelBuilder.Entity("Kyoo.Models.User", b => - { - b.Navigation("CurrentlyWatching"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/back/src/Kyoo.SqLite/SqLiteContext.cs b/back/src/Kyoo.SqLite/SqLiteContext.cs deleted file mode 100644 index 3a0cf6b9..00000000 --- a/back/src/Kyoo.SqLite/SqLiteContext.cs +++ /dev/null @@ -1,201 +0,0 @@ -// 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 . - -using System; -using System.Collections.Generic; -using System.Linq.Expressions; -using System.Reflection; -using Kyoo.Abstractions.Models; -using Kyoo.Database; -using Kyoo.Utils; -using Microsoft.Data.Sqlite; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Newtonsoft.Json; - -namespace Kyoo.SqLite -{ - /// - /// A sqlite implementation of . - /// - public class SqLiteContext : DatabaseContext - { - /// - /// The connection string to use. - /// - private readonly string _connection; - - /// - /// Is this instance in debug mode? - /// - private readonly bool _debugMode; - - /// - /// Should the configure step be skipped? This is used when the database is created via DbContextOptions. - /// - private readonly bool _skipConfigure; - - /// - /// A basic constructor that set default values (query tracker behaviors, mapping enums...) - /// - public SqLiteContext() - { } - - /// - /// Create a new using specific options - /// - /// The options to use. - public SqLiteContext(DbContextOptions options) - : base(options) - { - _skipConfigure = true; - } - - /// - /// A basic constructor that set default values (query tracker behaviors, mapping enums...) - /// - /// The connection string to use - /// Is this instance in debug mode? - public SqLiteContext(string connection, bool debugMode) - { - _connection = connection; - _debugMode = debugMode; - } - - /// - /// Set connection information for this database context - /// - /// An option builder to fill. - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - if (!_skipConfigure) - { - if (_connection != null) - optionsBuilder.UseSqlite(_connection); - else - optionsBuilder.UseSqlite(); - if (_debugMode) - optionsBuilder.EnableDetailedErrors().EnableSensitiveDataLogging(); - } - - base.OnConfiguring(optionsBuilder); - } - - /// - /// Set database parameters to support every types of Kyoo. - /// - /// The database's model builder. - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - ValueConverter arrayConvertor = new( - x => string.Join(";", x), - x => x.Split(';', StringSplitOptions.None)); - modelBuilder.Entity() - .Property(x => x.Paths) - .HasConversion(arrayConvertor); - modelBuilder.Entity() - .Property(x => x.Aliases) - .HasConversion(arrayConvertor); - modelBuilder.Entity() - .Property(x => x.Permissions) - .HasConversion(arrayConvertor); - - modelBuilder.Entity() - .Property(x => x.Status) - .HasConversion(); - modelBuilder.Entity() - .Property(x => x.Type) - .HasConversion(); - - ValueConverter, string> extraDataConvertor = new( - x => JsonConvert.SerializeObject(x), - x => JsonConvert.DeserializeObject>(x)); - modelBuilder.Entity() - .Property(x => x.ExtraData) - .HasConversion(extraDataConvertor); - - ValueConverter, string> jsonConvertor = new( - x => JsonConvert.SerializeObject(x), - x => JsonConvert.DeserializeObject>(x)); - modelBuilder.Entity() - .Property(x => x.Images) - .HasConversion(jsonConvertor); - modelBuilder.Entity() - .Property(x => x.Images) - .HasConversion(jsonConvertor); - modelBuilder.Entity() - .Property(x => x.Images) - .HasConversion(jsonConvertor); - modelBuilder.Entity() - .Property(x => x.Images) - .HasConversion(jsonConvertor); - modelBuilder.Entity() - .Property(x => x.Images) - .HasConversion(jsonConvertor); - modelBuilder.Entity() - .Property(x => x.Images) - .HasConversion(jsonConvertor); - modelBuilder.Entity() - .Property(x => x.Images) - .HasConversion(jsonConvertor); - modelBuilder.Entity() - .Property(x => x.Images) - .HasConversion(jsonConvertor); - - modelBuilder.Entity() - .ToView("LibraryItems") - .HasKey(x => x.ID); - base.OnModelCreating(modelBuilder); - } - - /// - protected override string MetadataName() - { - return typeof(T).Name + nameof(MetadataID); - } - - /// - protected override string LinkName() - { - return "Link" + typeof(T).Name + typeof(T2).Name; - } - - /// - protected override string LinkNameFk() - { - return typeof(T).Name + "ID"; - } - - /// - protected override bool IsDuplicateException(Exception ex) - { - return ex.InnerException - is SqliteException { SqliteExtendedErrorCode: 2067 /* SQLITE_CONSTRAINT_UNIQUE */ } - or SqliteException { SqliteExtendedErrorCode: 1555 /* SQLITE_CONSTRAINT_PRIMARYKEY */ }; - } - - /// - public override Expression> Like(Expression> query, string format) - { - MethodInfo iLike = MethodOfUtils.MethodOf(EF.Functions.Like); - MethodCallExpression call = Expression.Call(iLike, Expression.Constant(EF.Functions), query.Body, Expression.Constant(format)); - - return Expression.Lambda>(call, query.Parameters); - } - } -} diff --git a/back/src/Kyoo.SqLite/SqLiteModule.cs b/back/src/Kyoo.SqLite/SqLiteModule.cs deleted file mode 100644 index 90b741c4..00000000 --- a/back/src/Kyoo.SqLite/SqLiteModule.cs +++ /dev/null @@ -1,90 +0,0 @@ -// 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 . - -using System; -using System.Collections.Generic; -using Kyoo.Abstractions.Controllers; -using Kyoo.Database; -using Microsoft.AspNetCore.Hosting; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; - -namespace Kyoo.SqLite -{ - /// - /// A module to add sqlite capacity to the app. - /// - public class SqLiteModule : IPlugin - { - /// - public string Slug => "sqlite"; - - /// - public string Name => "SqLite"; - - /// - public string Description => "A database context for sqlite."; - - /// - public Dictionary Configuration => new(); - - /// - public bool Enabled => _configuration.GetSelectedDatabase() == "sqlite"; - - /// - /// The configuration to use. The database connection string is pulled from it. - /// - private readonly IConfiguration _configuration; - - /// - /// The host environment to check if the app is in debug mode. - /// - private readonly IWebHostEnvironment _environment; - - /// - /// Create a new postgres module instance and use the given configuration and environment. - /// - /// The configuration to use - /// The environment that will be used (if the env is in development mode, more information will be displayed on errors. - public SqLiteModule(IConfiguration configuration, IWebHostEnvironment env) - { - _configuration = configuration; - _environment = env; - } - - /// - public void Configure(IServiceCollection services) - { - services.AddDbContext(x => - { - x.UseSqlite(_configuration.GetDatabaseConnection("sqlite")); - if (_environment.IsDevelopment()) - x.EnableDetailedErrors().EnableSensitiveDataLogging(); - }, ServiceLifetime.Transient); - } - - /// - public void Initialize(IServiceProvider provider) - { - DatabaseContext context = provider.GetRequiredService(); - context.Database.Migrate(); - } - } -} diff --git a/back/tests/Kyoo.Tests/Database/RepositoryActivator.cs b/back/tests/Kyoo.Tests/Database/RepositoryActivator.cs index e049fcda..3cf83295 100644 --- a/back/tests/Kyoo.Tests/Database/RepositoryActivator.cs +++ b/back/tests/Kyoo.Tests/Database/RepositoryActivator.cs @@ -24,7 +24,7 @@ using Kyoo.Core.Controllers; using Kyoo.Database; using Xunit.Abstractions; -namespace Kyoo.Tests +namespace Kyoo.Tests.Database { public class RepositoryActivator : IDisposable, IAsyncDisposable { @@ -35,9 +35,7 @@ namespace Kyoo.Tests public RepositoryActivator(ITestOutputHelper output, PostgresFixture postgres = null) { - Context = postgres == null - ? new SqLiteTestContext(output) - : new PostgresTestContext(postgres, output); + Context = new PostgresTestContext(postgres, output); ProviderRepository provider = new(_NewContext()); LibraryRepository library = new(_NewContext(), provider); diff --git a/back/tests/Kyoo.Tests/Database/RepositoryTests.cs b/back/tests/Kyoo.Tests/Database/RepositoryTests.cs index b8454751..82f3d420 100644 --- a/back/tests/Kyoo.Tests/Database/RepositoryTests.cs +++ b/back/tests/Kyoo.Tests/Database/RepositoryTests.cs @@ -27,7 +27,7 @@ using Kyoo.Abstractions.Models.Exceptions; using Kyoo.Database; using Xunit; -namespace Kyoo.Tests +namespace Kyoo.Tests.Database { public abstract class RepositoryTests : IDisposable, IAsyncDisposable where T : class, IResource, new() diff --git a/back/tests/Kyoo.Tests/Database/TestContext.cs b/back/tests/Kyoo.Tests/Database/TestContext.cs index 933bda0d..dc95bc16 100644 --- a/back/tests/Kyoo.Tests/Database/TestContext.cs +++ b/back/tests/Kyoo.Tests/Database/TestContext.cs @@ -20,8 +20,6 @@ using System; using System.Threading.Tasks; using Kyoo.Database; using Kyoo.Postgresql; -using Kyoo.SqLite; -using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using Npgsql; @@ -30,55 +28,6 @@ using Xunit.Abstractions; namespace Kyoo.Tests { - public sealed class SqLiteTestContext : TestContext - { - /// - /// The internal sqlite connection used by all context returned by this class. - /// - private readonly SqliteConnection _connection; - - /// - /// The context's options that specify to use an in memory Sqlite database. - /// - private readonly DbContextOptions _context; - - public SqLiteTestContext(ITestOutputHelper output) - { - _connection = new SqliteConnection("DataSource=:memory:"); - _connection.Open(); - - _context = new DbContextOptionsBuilder() - .UseSqlite(_connection) - .UseLoggerFactory(LoggerFactory.Create(x => - { - x.ClearProviders(); - x.AddXunit(output); - })) - .EnableSensitiveDataLogging() - .EnableDetailedErrors() - .Options; - - using DatabaseContext context = New(); - context.Database.Migrate(); - TestSample.FillDatabase(context); - } - - public override void Dispose() - { - _connection.Close(); - } - - public override async ValueTask DisposeAsync() - { - await _connection.CloseAsync(); - } - - public override DatabaseContext New() - { - return new SqLiteContext(_context); - } - } - [CollectionDefinition(nameof(Postgresql))] public class PostgresCollection : ICollectionFixture { } diff --git a/back/tests/Kyoo.Tests/Kyoo.Tests.csproj b/back/tests/Kyoo.Tests/Kyoo.Tests.csproj index e84fa386..06e07d29 100644 --- a/back/tests/Kyoo.Tests/Kyoo.Tests.csproj +++ b/back/tests/Kyoo.Tests/Kyoo.Tests.csproj @@ -29,7 +29,6 @@ - diff --git a/docker-compose.yml b/docker-compose.yml index 566d0e27..8122d812 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,13 +4,9 @@ services: back: build: ./back restart: on-failure - environment: + env_file: + - ./.env - KYOO_DATADIR=/var/lib/kyoo - - DATABASE__ENABLED=postgres - - DATABASE__CONFIGURATIONS__POSTGRES__SERVER=postgres - - DATABASE__CONFIGURATIONS__POSTGRES__USER=${POSTGRES_USER} - - DATABASE__CONFIGURATIONS__POSTGRES__PASSWORD=${POSTGRES_PASSWORD} - - DATABASE__CONFIGURATIONS__POSTGRES__DATABASE=${POSTGRES_DB} - TVDB__APIKEY=${TVDB__APIKEY} - THEMOVIEDB__APIKEY=${THEMOVIEDB__APIKEY} - LIBRARY_ROOT=/video @@ -43,10 +39,8 @@ services: postgres: image: postgres restart: on-failure - environment: - - POSTGRES_USER=${POSTGRES_USER} - - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} - - POSTGRES_DB=${POSTGRES_DB} + env_file: + - ./.env volumes: - db:/var/lib/postgresql/data