Making sqlite work

This commit is contained in:
Zoe Roux 2021-05-29 15:10:59 +02:00
parent 19e64e8d72
commit d05e7a24b7
7 changed files with 36 additions and 21 deletions

View File

@ -8,14 +8,14 @@
<LangVersion>default</LangVersion> <LangVersion>default</LangVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <!-- <PropertyGroup>-->
<OutputPath>../Kyoo/bin/$(Configuration)/$(TargetFramework)/plugins/postgresql</OutputPath> <!-- <OutputPath>../Kyoo/bin/$(Configuration)/$(TargetFramework)/plugins/postgresql</OutputPath>-->
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <!-- <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>-->
<ProduceReferenceAssembly>false</ProduceReferenceAssembly> <!-- <ProduceReferenceAssembly>false</ProduceReferenceAssembly>-->
<GenerateDependencyFile>false</GenerateDependencyFile> <!-- <GenerateDependencyFile>false</GenerateDependencyFile>-->
<GenerateRuntimeConfigurationFiles>false</GenerateRuntimeConfigurationFiles> <!-- <GenerateRuntimeConfigurationFiles>false</GenerateRuntimeConfigurationFiles>-->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <!-- <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>-->
</PropertyGroup> <!-- </PropertyGroup>-->
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.5"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.5">

View File

@ -6,17 +6,17 @@
<Authors>Zoe Roux</Authors> <Authors>Zoe Roux</Authors>
<RepositoryUrl>https://github.com/AnonymusRaccoon/Kyoo</RepositoryUrl> <RepositoryUrl>https://github.com/AnonymusRaccoon/Kyoo</RepositoryUrl>
<LangVersion>default</LangVersion> <LangVersion>default</LangVersion>
<RootNamespace>Kyoo.SQLite</RootNamespace> <RootNamespace>Kyoo.SqLite</RootNamespace>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <!-- <PropertyGroup>-->
<OutputPath>../Kyoo/bin/$(Configuration)/$(TargetFramework)/plugins/sqlite</OutputPath> <!-- <OutputPath>../Kyoo/bin/$(Configuration)/$(TargetFramework)/plugins/sqlite</OutputPath>-->
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <!-- <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>-->
<ProduceReferenceAssembly>false</ProduceReferenceAssembly> <!-- <ProduceReferenceAssembly>false</ProduceReferenceAssembly>-->
<GenerateDependencyFile>false</GenerateDependencyFile> <!-- <GenerateDependencyFile>false</GenerateDependencyFile>-->
<GenerateRuntimeConfigurationFiles>false</GenerateRuntimeConfigurationFiles> <!-- <GenerateRuntimeConfigurationFiles>false</GenerateRuntimeConfigurationFiles>-->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <!-- <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>-->
</PropertyGroup> <!-- </PropertyGroup>-->
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.5"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.5">

View File

@ -56,8 +56,8 @@ namespace Kyoo.SqLite
_configuration = configuration; _configuration = configuration;
_environment = env; _environment = env;
} }
/// <inheritdoc /> /// <inheritdoc />
public void Configure(IServiceCollection services, ICollection<Type> availableTypes) public void Configure(IServiceCollection services, ICollection<Type> availableTypes)
{ {
@ -68,5 +68,12 @@ namespace Kyoo.SqLite
x.EnableDetailedErrors().EnableSensitiveDataLogging(); x.EnableDetailedErrors().EnableSensitiveDataLogging();
}); });
} }
/// <inheritdoc />
public void Initialize(IServiceProvider provider)
{
DatabaseContext context = provider.GetRequiredService<DatabaseContext>();
context.Database.Migrate();
}
} }
} }

View File

@ -14,7 +14,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">

View File

@ -46,6 +46,9 @@
<!-- <ExcludeAssets>all</ExcludeAssets>--> <!-- <ExcludeAssets>all</ExcludeAssets>-->
</ProjectReference> </ProjectReference>
<ProjectReference Include="../Kyoo.Authentication/Kyoo.Authentication.csproj"> <ProjectReference Include="../Kyoo.Authentication/Kyoo.Authentication.csproj">
<!-- <ExcludeAssets>all</ExcludeAssets>-->
</ProjectReference>
<ProjectReference Include="../Kyoo.SqLite/Kyoo.SqLite.csproj">
<!-- <ExcludeAssets>all</ExcludeAssets>--> <!-- <ExcludeAssets>all</ExcludeAssets>-->
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>

View File

@ -5,6 +5,7 @@ using Kyoo.Controllers;
using Kyoo.Models; using Kyoo.Models;
using Kyoo.Models.Options; using Kyoo.Models.Options;
using Kyoo.Postgresql; using Kyoo.Postgresql;
using Kyoo.SqLite;
using Kyoo.Tasks; using Kyoo.Tasks;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
@ -46,7 +47,8 @@ namespace Kyoo
// TODO remove postgres from here and load it like a normal plugin. // TODO remove postgres from here and load it like a normal plugin.
_plugins.LoadPlugins(new IPlugin[] { _plugins.LoadPlugins(new IPlugin[] {
new CoreModule(configuration), new CoreModule(configuration),
new PostgresModule(configuration, host), // new PostgresModule(configuration, host),
new SqLiteModule(configuration, host),
new AuthenticationModule(configuration, loggerFactory, host) new AuthenticationModule(configuration, loggerFactory, host)
}); });
} }

View File

@ -10,6 +10,10 @@
}, },
"database": { "database": {
"sqlite": {
"data Source": "kyoo.db",
"cache": "Shared"
},
"postgres": { "postgres": {
"server": "127.0.0.1", "server": "127.0.0.1",
"port": "5432", "port": "5432",