Skip to content

Commit

Permalink
feat: Support PostgreSQL (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
wzh425 authored Dec 6, 2024
1 parent 04c35da commit 47b5552
Show file tree
Hide file tree
Showing 30 changed files with 1,801 additions and 32 deletions.
5 changes: 3 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project>
<PropertyGroup>
<MasaFrameworkPackageVersion>1.2.0-preview.2</MasaFrameworkPackageVersion>
<MasaStackSdksPackageVersion>1.2.1-preview.4</MasaStackSdksPackageVersion>
<MasaFrameworkPackageVersion>1.2.0-preview.5</MasaFrameworkPackageVersion>
<MasaStackSdksPackageVersion>1.2.1-preview.8</MasaStackSdksPackageVersion>
<MicrosoftPackageVersion>6.0.8</MicrosoftPackageVersion>
</PropertyGroup>
</Project>
22 changes: 22 additions & 0 deletions Masa.Alert.sln
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Masa.Alert.NotificationServ
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Masa.Alert.Infrastructure.Constants", "src\Infrastructure\Masa.Alert.Infrastructure.Constants\Masa.Alert.Infrastructure.Constants.csproj", "{AFF871EB-653E-460D-9A64-C1944E8F76B3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Masa.Alert.EntityFrameworkCore.SqlServer", "src\Infrastructure\Masa.Alert.EntityFrameworkCore.SqlServer\Masa.Alert.EntityFrameworkCore.SqlServer.csproj", "{4557C624-8748-44FC-9795-7E0A9E7E4CF7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Masa.Alert.EntityFrameworkCore.PostgreSql", "src\Infrastructure\Masa.Alert.EntityFrameworkCore.PostgreSql\Masa.Alert.EntityFrameworkCore.PostgreSql.csproj", "{27A5AB4D-4447-47B0-9A44-E6511F58AA68}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -222,6 +226,22 @@ Global
{AFF871EB-653E-460D-9A64-C1944E8F76B3}.Release|Any CPU.Build.0 = Release|Any CPU
{AFF871EB-653E-460D-9A64-C1944E8F76B3}.Release|x86.ActiveCfg = Release|Any CPU
{AFF871EB-653E-460D-9A64-C1944E8F76B3}.Release|x86.Build.0 = Release|Any CPU
{4557C624-8748-44FC-9795-7E0A9E7E4CF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4557C624-8748-44FC-9795-7E0A9E7E4CF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4557C624-8748-44FC-9795-7E0A9E7E4CF7}.Debug|x86.ActiveCfg = Debug|Any CPU
{4557C624-8748-44FC-9795-7E0A9E7E4CF7}.Debug|x86.Build.0 = Debug|Any CPU
{4557C624-8748-44FC-9795-7E0A9E7E4CF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4557C624-8748-44FC-9795-7E0A9E7E4CF7}.Release|Any CPU.Build.0 = Release|Any CPU
{4557C624-8748-44FC-9795-7E0A9E7E4CF7}.Release|x86.ActiveCfg = Release|Any CPU
{4557C624-8748-44FC-9795-7E0A9E7E4CF7}.Release|x86.Build.0 = Release|Any CPU
{27A5AB4D-4447-47B0-9A44-E6511F58AA68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{27A5AB4D-4447-47B0-9A44-E6511F58AA68}.Debug|Any CPU.Build.0 = Debug|Any CPU
{27A5AB4D-4447-47B0-9A44-E6511F58AA68}.Debug|x86.ActiveCfg = Debug|Any CPU
{27A5AB4D-4447-47B0-9A44-E6511F58AA68}.Debug|x86.Build.0 = Debug|Any CPU
{27A5AB4D-4447-47B0-9A44-E6511F58AA68}.Release|Any CPU.ActiveCfg = Release|Any CPU
{27A5AB4D-4447-47B0-9A44-E6511F58AA68}.Release|Any CPU.Build.0 = Release|Any CPU
{27A5AB4D-4447-47B0-9A44-E6511F58AA68}.Release|x86.ActiveCfg = Release|Any CPU
{27A5AB4D-4447-47B0-9A44-E6511F58AA68}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -252,6 +272,8 @@ Global
{45550B8B-17A9-45D5-BA03-F2C9905E353D} = {BE3519B8-A573-4C5D-B48C-1FA3CE1E4473}
{603BEBB8-1563-4286-9CF1-73BC07749AD9} = {4660010F-BB9B-4C8E-B4F7-34AF77080EA0}
{AFF871EB-653E-460D-9A64-C1944E8F76B3} = {4660010F-BB9B-4C8E-B4F7-34AF77080EA0}
{4557C624-8748-44FC-9795-7E0A9E7E4CF7} = {4660010F-BB9B-4C8E-B4F7-34AF77080EA0}
{27A5AB4D-4447-47B0-9A44-E6511F58AA68} = {4660010F-BB9B-4C8E-B4F7-34AF77080EA0}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B83BA2BA-19E5-41FB-A92A-16A03DA229E4}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.

namespace Masa.Alert.EntityFrameworkCore;

public class AlertPostgreSqlDbContextFactory : IDesignTimeDbContextFactory<AlertDbContext>
{
public AlertDbContext CreateDbContext(string[] args)
{
AlertDbContext.RegisterAssembly(typeof(AlertPostgreSqlDbContextFactory).Assembly);
var optionsBuilder = new MasaDbContextOptionsBuilder<AlertDbContext>();
var configurationBuilder = new ConfigurationBuilder();
var configuration = configurationBuilder
.AddJsonFile("appsettings.PostgreSql.json")
.Build();
optionsBuilder.UseNpgsql(configuration.GetConnectionString("DefaultConnection")!, b => b.MigrationsAssembly("Masa.Alert.EntityFrameworkCore.PostgreSql"));

return new AlertDbContext(optionsBuilder.MasaOptions);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Masa.Alert.EntityFrameworkCore\Masa.Alert.EntityFrameworkCore.csproj" />
<PackageReference Include="Masa.Contrib.Authentication.OpenIdConnect.EFCore.PostgreSql" Version="$(MasaFrameworkPackageVersion)" />
<PackageReference Include="Masa.Contrib.Data.EFCore.PostgreSql" Version="$(MasaFrameworkPackageVersion)" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="$(MicrosoftPackageVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="$(MicrosoftPackageVersion)">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<None Update="appsettings.PostgreSql.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Loading

0 comments on commit 47b5552

Please sign in to comment.