Skip to content

Commit 739a3e4

Browse files
committed
merge the code
2 parents 0c287bb + 1def8a9 commit 739a3e4

File tree

7 files changed

+34
-23
lines changed

7 files changed

+34
-23
lines changed

Mystique.Core.Mvc/Infrastructure/MystiqueStartup.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using Mystique.Core.Contracts;
1717
using Mystique.Core.Helpers;
1818
using Mystique.Core.Models;
19+
using Mystique.Core.Repository.MySql;
1920
using Mystique.Core.Repositories;
2021
using Mystique.Mvc.Infrastructure;
2122
using System;
@@ -47,7 +48,7 @@ public static void MystiqueSetup(this IServiceCollection services, IConfiguratio
4748

4849
services.AddSingleton<IMvcModuleSetup, MvcModuleSetup>();
4950
services.AddScoped<IPluginManager, PluginManager>();
50-
services.AddScoped<IUnitOfWork, UnitOfWork>();
51+
services.AddScoped<IUnitOfWork, Repository.MySql.UnitOfWork>();
5152
services.AddSingleton<INotificationRegister, NotificationRegister>();
5253
services.AddSingleton<IActionDescriptorChangeProvider>(MystiqueActionDescriptorChangeProvider.Instance);
5354
services.AddSingleton<IReferenceContainer, DefaultReferenceContainer>();

Mystique.Core.Mvc/Mystique.Core.Mvc.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
<ItemGroup>
1313
<ProjectReference Include="..\Mystique.Core\Mystique.Core.csproj" />
14+
<ProjectReference Include="..\Mystique.Core.Repository.MySql\Mystique.Core.Repository.MySql.csproj" />
1415
</ItemGroup>
1516

1617

Mystique.Core.Repository.MySql/Migrations/202005282045.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public override void Up()
1212
.WithColumn("PluginId").AsGuid().PrimaryKey()
1313
.WithColumn("UniqueKey").AsString().NotNullable()
1414
.WithColumn("Name").AsString().NotNullable()
15+
.WithColumn("DisplayName").AsString().NotNullable()
1516
.WithColumn("Version").AsString().NotNullable()
1617
.WithColumn("Enable").AsInt16().NotNullable();
1718

Mystique.sln

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DemoPlugin1", "DemoPlugin1\
99
EndProject
1010
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mystique.Core", "Mystique.Core\Mystique.Core.csproj", "{51262BFE-1E31-4317-A920-9F127C111712}"
1111
EndProject
12-
Project("{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}") = "Mystique.Database", "Mystique.Database\Mystique.Database.sqlproj", "{6E246A60-A973-4C51-AC97-FF607D7CEC1B}"
13-
EndProject
1412
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{93F71C5A-FEB8-4BDC-89C5-2382DE5B079E}"
1513
ProjectSection(SolutionItems) = preProject
1614
Nuget.Config = Nuget.Config
@@ -77,24 +75,6 @@ Global
7775
{51262BFE-1E31-4317-A920-9F127C111712}.Release|x64.Build.0 = Release|Any CPU
7876
{51262BFE-1E31-4317-A920-9F127C111712}.Release|x86.ActiveCfg = Release|Any CPU
7977
{51262BFE-1E31-4317-A920-9F127C111712}.Release|x86.Build.0 = Release|Any CPU
80-
{6E246A60-A973-4C51-AC97-FF607D7CEC1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
81-
{6E246A60-A973-4C51-AC97-FF607D7CEC1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
82-
{6E246A60-A973-4C51-AC97-FF607D7CEC1B}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
83-
{6E246A60-A973-4C51-AC97-FF607D7CEC1B}.Debug|x64.ActiveCfg = Debug|Any CPU
84-
{6E246A60-A973-4C51-AC97-FF607D7CEC1B}.Debug|x64.Build.0 = Debug|Any CPU
85-
{6E246A60-A973-4C51-AC97-FF607D7CEC1B}.Debug|x64.Deploy.0 = Debug|Any CPU
86-
{6E246A60-A973-4C51-AC97-FF607D7CEC1B}.Debug|x86.ActiveCfg = Debug|Any CPU
87-
{6E246A60-A973-4C51-AC97-FF607D7CEC1B}.Debug|x86.Build.0 = Debug|Any CPU
88-
{6E246A60-A973-4C51-AC97-FF607D7CEC1B}.Debug|x86.Deploy.0 = Debug|Any CPU
89-
{6E246A60-A973-4C51-AC97-FF607D7CEC1B}.Release|Any CPU.ActiveCfg = Release|Any CPU
90-
{6E246A60-A973-4C51-AC97-FF607D7CEC1B}.Release|Any CPU.Build.0 = Release|Any CPU
91-
{6E246A60-A973-4C51-AC97-FF607D7CEC1B}.Release|Any CPU.Deploy.0 = Release|Any CPU
92-
{6E246A60-A973-4C51-AC97-FF607D7CEC1B}.Release|x64.ActiveCfg = Release|Any CPU
93-
{6E246A60-A973-4C51-AC97-FF607D7CEC1B}.Release|x64.Build.0 = Release|Any CPU
94-
{6E246A60-A973-4C51-AC97-FF607D7CEC1B}.Release|x64.Deploy.0 = Release|Any CPU
95-
{6E246A60-A973-4C51-AC97-FF607D7CEC1B}.Release|x86.ActiveCfg = Release|Any CPU
96-
{6E246A60-A973-4C51-AC97-FF607D7CEC1B}.Release|x86.Build.0 = Release|Any CPU
97-
{6E246A60-A973-4C51-AC97-FF607D7CEC1B}.Release|x86.Deploy.0 = Release|Any CPU
9878
{A4377E85-5F8B-4A2E-AE94-19616C646BA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
9979
{A4377E85-5F8B-4A2E-AE94-19616C646BA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
10080
{A4377E85-5F8B-4A2E-AE94-19616C646BA4}.Debug|x64.ActiveCfg = Debug|Any CPU

Mystique/Mystique.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9+
<PackageReference Include="FluentMigrator.Runner" Version="3.2.6" />
10+
<PackageReference Include="FluentMigrator.Runner.MySql" Version="3.2.6" />
911
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.0.0" />
1012
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />
1113
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0">
@@ -21,6 +23,7 @@
2123
<ItemGroup>
2224
<ProjectReference Include="..\Mystique.Core.Mvc\Mystique.Core.Mvc.csproj" />
2325
<ProjectReference Include="..\Mystique.Core\Mystique.Core.csproj" />
26+
<ProjectReference Include="..\Mystique.Core.Repository.MySql\Mystique.Core.Repository.MySql.csproj" />
2427
</ItemGroup>
2528

2629
<ItemGroup>

Mystique/Startup.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
using Microsoft.AspNetCore.Builder;
1+
using FluentMigrator.Runner;
2+
using Microsoft.AspNetCore.Builder;
23
using Microsoft.AspNetCore.Hosting;
34
using Microsoft.Extensions.Configuration;
45
using Microsoft.Extensions.DependencyInjection;
56
using Microsoft.Extensions.FileProviders;
67
using Microsoft.Extensions.Hosting;
78
using Mystique.Core.Mvc.Infrastructure;
9+
using Mystique.Core.Repository.MySql.Migrations;
810
using System;
911
using System.Threading;
1012

@@ -22,7 +24,27 @@ public Startup(IConfiguration configuration)
2224
// This method gets called by the runtime. Use this method to add services to the container.
2325
public void ConfigureServices(IServiceCollection services)
2426
{
27+
using (var scope = CreateServices().CreateScope())
28+
{
29+
var runner = scope.ServiceProvider.GetRequiredService<IMigrationRunner>();
30+
runner.MigrateUp();
31+
}
32+
2533
services.MystiqueSetup(Configuration);
34+
35+
36+
}
37+
38+
private static IServiceProvider CreateServices()
39+
{
40+
return new ServiceCollection().AddFluentMigratorCore().ConfigureRunner(rb =>
41+
rb.AddMySql5()
42+
.WithGlobalConnectionString("server=localhost;port=3306;Database=pluginDB;UID=root;PWD=123456")
43+
.ScanIn(typeof(InitialDB).Assembly)
44+
.For
45+
.Migrations())
46+
.AddLogging(lb => lb.AddFluentMigratorConsole())
47+
.BuildServiceProvider(false);
2648
}
2749

2850
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

Mystique/appsettings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
},
77
"AllowedHosts": "*",
88
"ConnectionStringSetting": {
9-
"ConnectionString": "Data Source=.;Initial Catalog=LamondTest;Integrated Security=True"
9+
"ConnectionString": "server=localhost;port=3306;Database=pluginDB;UID=root;PWD=123456"
10+
},
11+
"SiteSetings": {
12+
"MySQLConnection": "server=localhost;port=3306;Database=pluginDB;UID=root;PWD=123456"
1013
}
1114
}

0 commit comments

Comments
 (0)