-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #127 from NoxOrg/feature/postgres_database_provider
Feature/postgres database provider
- Loading branch information
Showing
80 changed files
with
837 additions
and
1,503 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
version: '3.7' | ||
|
||
volumes: | ||
postgres: | ||
|
||
services: | ||
postgres: | ||
container_name: postgres_container | ||
image: postgres:14-alpine | ||
restart: always | ||
environment: | ||
POSTGRES_DB: SampleCurrencyDb | ||
POSTGRES_USER: "sa" | ||
POSTGRES_PASSWORD: "Developer*123" | ||
PGDATA: ./data | ||
ports: | ||
- "54320:5432" | ||
volumes: | ||
- postgres:/var/lib/postgresql/data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
version: '3.7' | ||
|
||
volumes: | ||
sqlserver: | ||
|
||
services: | ||
sqlserver: | ||
container_name: sqlserver_container | ||
image: "mcr.microsoft.com/azure-sql-edge:latest" | ||
user: root | ||
ports: | ||
- "1433:1433" | ||
environment: | ||
SA_PASSWORD: "Developer*123" | ||
ACCEPT_EULA: "Y" | ||
MSSQL_PID: "Developer" | ||
volumes: | ||
- sqlserver:/var/opt/mssql/data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
version: '3.7' | ||
|
||
volumes: | ||
sqlserver: | ||
postgres: | ||
esdata: | ||
driver: local | ||
|
||
services: | ||
sqlserver: | ||
container_name: sqlserver_container | ||
image: "mcr.microsoft.com/azure-sql-edge:latest" | ||
user: root | ||
ports: | ||
- "1433:1433" | ||
environment: | ||
SA_PASSWORD: "Developer*123" | ||
ACCEPT_EULA: "Y" | ||
MSSQL_PID: "Developer" | ||
volumes: | ||
- sqlserver:/var/opt/mssql/data | ||
|
||
postgres: | ||
container_name: postgres_container | ||
image: postgres:14-alpine | ||
restart: always | ||
environment: | ||
POSTGRES_DB: SampleCurrencyDb | ||
POSTGRES_USER: "sa" | ||
POSTGRES_PASSWORD: "Developer*123" | ||
PGDATA: ./data | ||
ports: | ||
- "54320:5432" | ||
volumes: | ||
- postgres:/var/lib/postgresql/data | ||
|
||
apm-server: | ||
container_name: apm-server | ||
image: docker.elastic.co/apm/apm-server:7.17.10 | ||
depends_on: | ||
elasticsearch: | ||
condition: service_healthy | ||
kibana: | ||
condition: service_healthy | ||
cap_add: ["CHOWN", "DAC_OVERRIDE", "SETGID", "SETUID"] | ||
cap_drop: ["ALL"] | ||
ports: | ||
- 8200:8200 | ||
networks: | ||
- elastic | ||
command: > | ||
apm-server -e | ||
-E apm-server.rum.enabled=true | ||
-E setup.kibana.host=kibana:5601 | ||
-E setup.template.settings.index.number_of_replicas=0 | ||
-E apm-server.kibana.enabled=true | ||
-E apm-server.kibana.host=kibana:5601 | ||
-E output.elasticsearch.hosts=["elasticsearch:9200"] | ||
-E apm-server.kibana.username=elastic | ||
-E apm-server.kibana.password=Developer*123 | ||
-E output.elasticsearch.username=elastic | ||
-E output.elasticsearch.password=Developer*123 | ||
healthcheck: | ||
interval: 10s | ||
retries: 12 | ||
test: curl --write-out 'HTTP %{http_code}' --fail --silent --output /dev/null http://localhost:8200/ | ||
|
||
elasticsearch: | ||
container_name: elasticsearch | ||
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.10 | ||
environment: | ||
- bootstrap.memory_lock=true | ||
- cluster.name=docker-cluster | ||
- cluster.routing.allocation.disk.threshold_enabled=false | ||
- discovery.type=single-node | ||
- ES_JAVA_OPTS=-XX:UseAVX=2 -Xms1g -Xmx1g | ||
- xpack.security.enabled=true | ||
- xpack.security.authc.api_key.enabled=true | ||
- ELASTIC_PASSWORD=Developer*123 | ||
ulimits: | ||
memlock: | ||
hard: -1 | ||
soft: -1 | ||
volumes: | ||
- esdata:/usr/share/elasticsearch/data | ||
ports: | ||
- 9200:9200 | ||
networks: | ||
- elastic | ||
healthcheck: | ||
interval: 20s | ||
retries: 10 | ||
test: curl -s http://localhost:9200/_cluster/health | grep -vq '"status":"red"' | ||
|
||
kibana: | ||
container_name: kibana | ||
image: docker.elastic.co/kibana/kibana:7.17.10 | ||
depends_on: | ||
elasticsearch: | ||
condition: service_healthy | ||
environment: | ||
ELASTICSEARCH_URL: http://elasticsearch:9200 | ||
ELASTICSEARCH_HOSTS: http://elasticsearch:9200 | ||
ELASTICSEARCH_USERNAME: elastic | ||
ELASTICSEARCH_PASSWORD: Developer*123 | ||
ports: | ||
- 5601:5601 | ||
networks: | ||
- elastic | ||
healthcheck: | ||
test: | ||
[ | ||
"CMD-SHELL", | ||
"curl -s -I http://localhost:5601 | grep -q 'HTTP/1.1 302 Found'", | ||
] | ||
interval: 10s | ||
timeout: 10s | ||
retries: 120 | ||
|
||
networks: | ||
elastic: | ||
driver: bridge |
9 changes: 0 additions & 9 deletions
9
src/Nox.Abstractions/Infrastructure/Persistence/INoxDatabaseProvider.cs
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
src/Nox.EntityFramework.Postgres/Nox.EntityFramework.Postgres.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Nox.Types.EntityFramework\Nox.Types.EntityFramework.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" /> | ||
</ItemGroup> | ||
|
||
</Project> |
66 changes: 66 additions & 0 deletions
66
src/Nox.EntityFramework.Postgres/PostgresDatabaseProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Nox.Solution; | ||
using Nox.Types; | ||
using Nox.Types.EntityFramework.Abstractions; | ||
using Nox.Types.EntityFramework.Configurators; | ||
using Npgsql; | ||
|
||
namespace Nox.EntityFramework.Postgres; | ||
|
||
public class PostgresDatabaseProvider: NoxDatabaseConfigurator, INoxDatabaseProvider | ||
{ | ||
private string _connectionString = string.Empty; | ||
|
||
private static readonly Dictionary<NoxType, INoxTypeDatabaseConfigurator> TypesConfiguration = | ||
new() | ||
{ | ||
{ NoxType.Text, new PostgresTextDatabaseConfiguration() }, //Use Postgres Implementation | ||
{ NoxType.Number, new NumberDatabaseConfigurator() }, // use default implementation | ||
{ NoxType.Money, new MoneyDatabaseConfigurator() } // use default implementation | ||
}; | ||
|
||
public PostgresDatabaseProvider(): base(TypesConfiguration) | ||
{ | ||
|
||
} | ||
|
||
public string ConnectionString | ||
{ | ||
get => _connectionString; | ||
set => SetConnectionString(value); | ||
} | ||
|
||
public DbContextOptionsBuilder ConfigureDbContext(DbContextOptionsBuilder optionsBuilder, string applicationName, DatabaseServer dbServer) | ||
{ | ||
var csb = new NpgsqlConnectionStringBuilder(dbServer.Options) | ||
{ | ||
Host = dbServer.ServerUri, | ||
Port = dbServer.Port ?? 5432, | ||
Username = dbServer.User, | ||
Password = dbServer.Password, | ||
Database = dbServer.Name, | ||
ApplicationName = applicationName, | ||
}; | ||
SetConnectionString(csb.ConnectionString); | ||
|
||
return optionsBuilder.UseNpgsql(_connectionString, opts => | ||
{ | ||
opts.MigrationsHistoryTable("MigrationsHistory", "migrations"); | ||
}); | ||
} | ||
|
||
public string ToTableNameForSql(string table, string schema) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public string ToTableNameForSqlRaw(string table, string schema) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
private void SetConnectionString(string connectionString) | ||
{ | ||
_connectionString = connectionString; | ||
} | ||
} |
5 changes: 3 additions & 2 deletions
5
...gres/PostgresTextDatabaseConfiguration.cs → ...gres/PostgresTextDatabaseConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/Nox.EntityFramework.SqlServer/Nox.EntityFramework.SqlServer.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Nox.Types.EntityFramework\Nox.Types.EntityFramework.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.8" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.