Skip to content

Commit

Permalink
Created a PostgreSQL project. (#56)
Browse files Browse the repository at this point in the history
* Created a PostgreSQL project.

* Deleted existing migrations.

* Completed migrations and integration tests.
  • Loading branch information
Utar94 authored Mar 5, 2024
1 parent 5d154bc commit 3bb25bd
Show file tree
Hide file tree
Showing 81 changed files with 4,943 additions and 9,917 deletions.
22 changes: 21 additions & 1 deletion Identity.sln
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Logitar.Identity.Infrastruc
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Logitar.Identity.Tests", "tests\Logitar.Identity.Tests\Logitar.Identity.Tests.csproj", "{D0781AC3-5827-4DAE-BBAD-481634FF3C0F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logitar.Identity.Contracts", "src\Logitar.Identity.Contracts\Logitar.Identity.Contracts.csproj", "{0E9D9B1A-B62C-4036-91B8-6E34CAA5F938}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Logitar.Identity.Contracts", "src\Logitar.Identity.Contracts\Logitar.Identity.Contracts.csproj", "{0E9D9B1A-B62C-4036-91B8-6E34CAA5F938}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logitar.Identity.EntityFrameworkCore.PostgreSQL", "src\Logitar.Identity.EntityFrameworkCore.PostgreSQL\Logitar.Identity.EntityFrameworkCore.PostgreSQL.csproj", "{B06204BC-FE92-4C5E-9A70-25D100AB5857}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logitar.Identity.EFCore.Relational.IntegrationTests", "tests\Logitar.Identity.EFCore.Relational.IntegrationTests\Logitar.Identity.EFCore.Relational.IntegrationTests.csproj", "{5C6B80B4-D3BA-4DE0-928A-E4F5BA9529CA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logitar.Identity.EFCore.PostgreSQL.IntegrationTests", "tests\Logitar.Identity.EFCore.PostgreSQL.IntegrationTests\Logitar.Identity.EFCore.PostgreSQL.IntegrationTests.csproj", "{FBB0D3D5-0282-4E6A-9B03-144CC1347072}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -82,6 +88,18 @@ Global
{0E9D9B1A-B62C-4036-91B8-6E34CAA5F938}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0E9D9B1A-B62C-4036-91B8-6E34CAA5F938}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0E9D9B1A-B62C-4036-91B8-6E34CAA5F938}.Release|Any CPU.Build.0 = Release|Any CPU
{B06204BC-FE92-4C5E-9A70-25D100AB5857}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B06204BC-FE92-4C5E-9A70-25D100AB5857}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B06204BC-FE92-4C5E-9A70-25D100AB5857}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B06204BC-FE92-4C5E-9A70-25D100AB5857}.Release|Any CPU.Build.0 = Release|Any CPU
{5C6B80B4-D3BA-4DE0-928A-E4F5BA9529CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5C6B80B4-D3BA-4DE0-928A-E4F5BA9529CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5C6B80B4-D3BA-4DE0-928A-E4F5BA9529CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5C6B80B4-D3BA-4DE0-928A-E4F5BA9529CA}.Release|Any CPU.Build.0 = Release|Any CPU
{FBB0D3D5-0282-4E6A-9B03-144CC1347072}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FBB0D3D5-0282-4E6A-9B03-144CC1347072}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FBB0D3D5-0282-4E6A-9B03-144CC1347072}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FBB0D3D5-0282-4E6A-9B03-144CC1347072}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -91,6 +109,8 @@ Global
{FA9AB722-026B-4842-B888-E9824568CBC1} = {BCB8A692-DF88-4E50-91A7-AD91E466559C}
{04C669C6-0B63-45A1-8F0F-16A7E7FC023E} = {BCB8A692-DF88-4E50-91A7-AD91E466559C}
{D0781AC3-5827-4DAE-BBAD-481634FF3C0F} = {BCB8A692-DF88-4E50-91A7-AD91E466559C}
{5C6B80B4-D3BA-4DE0-928A-E4F5BA9529CA} = {BCB8A692-DF88-4E50-91A7-AD91E466559C}
{FBB0D3D5-0282-4E6A-9B03-144CC1347072} = {BCB8A692-DF88-4E50-91A7-AD91E466559C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {45FD7647-C5AB-4CE1-A93C-59A73FDD2196}
Expand Down
13 changes: 11 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ services:
ACCEPT_EULA: 'Y'
SA_PASSWORD: Ks875v3qctRxE6Z4

identity_postgres:
image: postgres
container_name: Logitar.Identity_postgres
ports:
- 5436:5432
environment:
POSTGRES_PASSWORD: zHSNLvy74Z3nUgcC

identity_demo:
build:
context: .
Expand All @@ -18,8 +26,9 @@ services:
depends_on:
- identity_mssql
restart: unless-stopped
ports:
- 8086:8080
environment:
ASPNETCORE_Environment: Development
POSTGRESQLCONNSTR_Identity: "User ID=postgres;Password=zHSNLvy74Z3nUgcC;Host=identity_postgres;Port=5432;Database=Identity;"
SQLCONNSTR_Identity: "Server=identity_mssql;Database=Identity;User Id=SA;Password=Ks875v3qctRxE6Z4;Persist Security Info=False;Encrypt=False;"
ports:
- 36190:8080
7 changes: 7 additions & 0 deletions src/Logitar.Identity.Demo/DatabaseProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Logitar.Identity.Demo;

internal enum DatabaseProvider
{
EntityFrameworkCorePostgreSQL,
EntityFrameworkCoreSqlServer
}
15 changes: 15 additions & 0 deletions src/Logitar.Identity.Demo/DatabaseProviderNotSupportedException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Logitar.Identity.Demo;

internal class DatabaseProviderNotSupportedException : NotSupportedException
{
public DatabaseProvider DatabaseProvider
{
get => (DatabaseProvider)Data[nameof(DatabaseProvider)]!;
private set => Data[nameof(DatabaseProvider)] = value;
}

public DatabaseProviderNotSupportedException(DatabaseProvider databaseProvider) : base($"The database provider '{databaseProvider}' is not supported.")
{
DatabaseProvider = databaseProvider;
}
}
9 changes: 9 additions & 0 deletions src/Logitar.Identity.Demo/Logitar.Identity.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<Content Remove="secrets.example.json" />
</ItemGroup>

<ItemGroup>
<None Include="secrets.example.json" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1">
<PrivateAssets>all</PrivateAssets>
Expand All @@ -27,6 +35,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Logitar.Identity.EntityFrameworkCore.PostgreSQL\Logitar.Identity.EntityFrameworkCore.PostgreSQL.csproj" />
<ProjectReference Include="..\Logitar.Identity.EntityFrameworkCore.SqlServer\Logitar.Identity.EntityFrameworkCore.SqlServer.csproj" />
</ItemGroup>

Expand Down
6 changes: 0 additions & 6 deletions src/Logitar.Identity.Demo/Logitar.Identity.Demo.http

This file was deleted.

20 changes: 17 additions & 3 deletions src/Logitar.Identity.Demo/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Logitar.Identity.EntityFrameworkCore.SqlServer;
using Logitar.Identity.EntityFrameworkCore.PostgreSQL;
using Logitar.Identity.EntityFrameworkCore.SqlServer;

namespace Logitar.Identity.Demo;

Expand Down Expand Up @@ -26,8 +27,21 @@ public override void ConfigureServices(IServiceCollection services)
services.AddSwaggerGen();
}

string connectionString = _configuration.GetValue<string>("SQLCONNSTR_Identity") ?? string.Empty;
services.AddLogitarIdentityWithEntityFrameworkCoreSqlServer(connectionString);
string connectionString;
DatabaseProvider databaseProvider = _configuration.GetValue<DatabaseProvider?>("DatabaseProvider") ?? DatabaseProvider.EntityFrameworkCoreSqlServer;
switch (databaseProvider)
{
case DatabaseProvider.EntityFrameworkCorePostgreSQL:
connectionString = _configuration.GetValue<string>("POSTGRESQLCONNSTR_Identity") ?? string.Empty;
services.AddLogitarIdentityWithEntityFrameworkCorePostgreSQL(connectionString);
break;
case DatabaseProvider.EntityFrameworkCoreSqlServer:
connectionString = _configuration.GetValue<string>("SQLCONNSTR_Identity") ?? string.Empty;
services.AddLogitarIdentityWithEntityFrameworkCoreSqlServer(connectionString);
break;
default:
throw new DatabaseProviderNotSupportedException(databaseProvider);
}
}

public override void Configure(IApplicationBuilder builder)
Expand Down
1 change: 1 addition & 0 deletions src/Logitar.Identity.Demo/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
"Microsoft.AspNetCore": "Warning"
}
},
"POSTGRESQLCONNSTR_Identity": "User ID=postgres;Password=zHSNLvy74Z3nUgcC;Host=host.docker.internal;Port=5436;Database=Identity;",
"SQLCONNSTR_Identity": "Server=host.docker.internal,1436;Database=Identity;User Id=SA;Password=Ks875v3qctRxE6Z4;Persist Security Info=False;Encrypt=False;"
}
3 changes: 3 additions & 0 deletions src/Logitar.Identity.Demo/secrets.example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"DatabaseProvider": "EntityFrameworkCorePostgreSQL"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Logitar.EventSourcing.EntityFrameworkCore.PostgreSQL;
using Logitar.Identity.EntityFrameworkCore.Relational;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;

namespace Logitar.Identity.EntityFrameworkCore.PostgreSQL;

public static class DependencyInjectionExtensions
{
public static IServiceCollection AddLogitarIdentityWithEntityFrameworkCorePostgreSQL(this IServiceCollection services, string connectionString)
{
return services
.AddDbContext<IdentityContext>(options => options.UseNpgsql(connectionString,
b => b.MigrationsAssembly("Logitar.Identity.EntityFrameworkCore.PostgreSQL")
))
.AddLogitarEventSourcingWithEntityFrameworkCorePostgreSQL(connectionString)
.AddLogitarIdentityWithEntityFrameworkCoreRelational()
.AddSingleton<ISqlHelper, PostgresHelper>();
}
}
21 changes: 21 additions & 0 deletions src/Logitar.Identity.EntityFrameworkCore.PostgreSQL/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Logitar

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Title>Logitar.Identity.EntityFrameworkCore.PostgreSQL</Title>
<Authors>Francis Pion</Authors>
<Company>Logitar</Company>
<Product>Logitar.Identity</Product>
<Description>Provides an implementation of a relational event store to be used with Identity management platform, Entity Framework Core and PostgreSQL.</Description>
<Copyright>© 2024 Logitar All Rights Reserved.</Copyright>
<PackageIcon>logitar.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/Logitar/Identity</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<AssemblyVersion>0.11.1.0</AssemblyVersion>
<FileVersion>$(AssemblyVersion)</FileVersion>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<Version>0.11.1</Version>
<NeutralLanguage>en-CA</NeutralLanguage>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
<PackageReleaseNotes>Updated NuGet packages.</PackageReleaseNotes>
<PackageTags>logitar;net;framework;identity;entityframeworkcore;postgres</PackageTags>
<PackageProjectUrl>https://github.com/Logitar/Identity/tree/main/src/Logitar.Identity.EntityFrameworkCore.PostgreSQL</PackageProjectUrl>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<None Update="LICENSE">
<PackagePath>\</PackagePath>
<Pack>True</Pack>
</None>
<None Update="logitar.png">
<PackagePath>\</PackagePath>
<Pack>True</Pack>
</None>
<None Update="README.md">
<PackagePath>\</PackagePath>
<Pack>True</Pack>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Logitar.Data.PostgreSQL" Version="3.0.0" />
<PackageReference Include="Logitar.EventSourcing.EntityFrameworkCore.PostgreSQL" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Logitar.Identity.EntityFrameworkCore.Relational\Logitar.Identity.EntityFrameworkCore.Relational.csproj" />
</ItemGroup>

</Project>
Loading

0 comments on commit 3bb25bd

Please sign in to comment.