diff --git a/NDB.Test.Api/NDB.Test.Api.csproj b/NDB.Test.Api/NDB.Test.Api.csproj
index 0cf9856..e913ef3 100644
--- a/NDB.Test.Api/NDB.Test.Api.csproj
+++ b/NDB.Test.Api/NDB.Test.Api.csproj
@@ -9,8 +9,10 @@
+
+
diff --git a/NDB.Test.Api/Program.cs b/NDB.Test.Api/Program.cs
index fe6c692..2e0db3a 100644
--- a/NDB.Test.Api/Program.cs
+++ b/NDB.Test.Api/Program.cs
@@ -1,11 +1,7 @@
using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
-using Microsoft.Extensions.Logging;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
+using System.Diagnostics;
+using System.IO;
namespace NDB.Test.Api
{
@@ -13,6 +9,10 @@ namespace NDB.Test.Api
{
public static void Main(string[] args)
{
+ var pathToExe = Process.GetCurrentProcess().MainModule.FileName;
+ var pathToContentRoot = Path.GetDirectoryName(pathToExe);
+ Directory.SetCurrentDirectory(pathToContentRoot);
+
CreateHostBuilder(args).Build().Run();
}
diff --git a/NDB.Test.Api/Startup.cs b/NDB.Test.Api/Startup.cs
index a33d886..7351f3d 100644
--- a/NDB.Test.Api/Startup.cs
+++ b/NDB.Test.Api/Startup.cs
@@ -6,6 +6,7 @@ using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
using NDB.Extensions.Swagger;
using NDB.Extensions.Swagger.Constants;
+using NDB.Infrastructure.DatabaseMigration;
using NDB.Test.Api.Extensions;
namespace NDB.Test.Api
@@ -27,6 +28,8 @@ namespace NDB.Test.Api
services.AddControllers();
services.AddSwagger("NDB.Test.Api", AuthorizationType.InhouseIdentity);
+
+ services.AddMigration();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@@ -49,6 +52,8 @@ namespace NDB.Test.Api
{
endpoints.MapControllers();
});
+
+ app.UseMigration();
}
}
}
diff --git a/NDB.Test.Api/appsettings.json b/NDB.Test.Api/appsettings.json
index 91185aa..1be2f95 100644
--- a/NDB.Test.Api/appsettings.json
+++ b/NDB.Test.Api/appsettings.json
@@ -1,4 +1,7 @@
{
+ "ConnectionStrings": {
+ "DatabaseConnection": "Data Source={Workspace}\\TesterDb.db"
+ },
"Logging": {
"LogLevel": {
"Default": "Information",
diff --git a/NDB.sln b/NDB.sln
index b787291..7e79dc7 100644
--- a/NDB.sln
+++ b/NDB.sln
@@ -58,7 +58,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{CCEE458E-0
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NDB.Test.Api", "NDB.Test.Api\NDB.Test.Api.csproj", "{F717BE3D-F5F4-4D99-B96D-D0A23E8BED01}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NDB.Infrastructure.DatabaseMigration", "infrastructure\NDB.Infrastructure.DatabaseMigration\NDB.Infrastructure.DatabaseMigration.csproj", "{74C7BE02-DD5C-49C2-8E88-E3AEA729E2AB}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NDB.Infrastructure.DatabaseMigration", "infrastructure\NDB.Infrastructure.DatabaseMigration\NDB.Infrastructure.DatabaseMigration.csproj", "{74C7BE02-DD5C-49C2-8E88-E3AEA729E2AB}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NDB.Test.Application", "test\NDB.Test.Application\NDB.Test.Application.csproj", "{87C39FDC-2BCF-445F-BF61-0DFB28FC1B26}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -110,6 +112,10 @@ Global
{74C7BE02-DD5C-49C2-8E88-E3AEA729E2AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74C7BE02-DD5C-49C2-8E88-E3AEA729E2AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74C7BE02-DD5C-49C2-8E88-E3AEA729E2AB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {87C39FDC-2BCF-445F-BF61-0DFB28FC1B26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {87C39FDC-2BCF-445F-BF61-0DFB28FC1B26}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {87C39FDC-2BCF-445F-BF61-0DFB28FC1B26}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {87C39FDC-2BCF-445F-BF61-0DFB28FC1B26}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -138,6 +144,7 @@ Global
{CCEE458E-02A8-42FD-8F5F-A35481A23303} = {E0202271-4E92-4DB8-900D-B5FD745B9278}
{F717BE3D-F5F4-4D99-B96D-D0A23E8BED01} = {CCEE458E-02A8-42FD-8F5F-A35481A23303}
{74C7BE02-DD5C-49C2-8E88-E3AEA729E2AB} = {1C1D634E-06CC-4707-9564-E31A76F27D9E}
+ {87C39FDC-2BCF-445F-BF61-0DFB28FC1B26} = {CCEE458E-02A8-42FD-8F5F-A35481A23303}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {87541BAB-3FAC-4ADB-A7FB-8228DA87843D}
diff --git a/test/NDB.Test.Application/Class1.cs b/test/NDB.Test.Application/Class1.cs
new file mode 100644
index 0000000..d86fb85
--- /dev/null
+++ b/test/NDB.Test.Application/Class1.cs
@@ -0,0 +1,8 @@
+using System;
+
+namespace NDB.Test.Application
+{
+ public class Class1
+ {
+ }
+}
diff --git a/test/NDB.Test.Application/NDB.Test.Application.csproj b/test/NDB.Test.Application/NDB.Test.Application.csproj
new file mode 100644
index 0000000..ad22449
--- /dev/null
+++ b/test/NDB.Test.Application/NDB.Test.Application.csproj
@@ -0,0 +1,16 @@
+
+
+
+ net5.0
+
+
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+
+
diff --git a/test/NDB.Test.Application/Scripts/1.0.0/01.Create table MimeType.sql b/test/NDB.Test.Application/Scripts/1.0.0/01.Create table MimeType.sql
new file mode 100644
index 0000000..7fe815b
--- /dev/null
+++ b/test/NDB.Test.Application/Scripts/1.0.0/01.Create table MimeType.sql
@@ -0,0 +1,18 @@
+CREATE TABLE "MimeType" (
+ "MimeTypeId" INTEGER NOT NULL,
+ "MimeTypeCode" TEXT NOT NULL UNIQUE,
+ "MimeTypeName" TEXT NOT NULL,
+ CONSTRAINT "PK_MimeType" PRIMARY KEY("MimeTypeId" AUTOINCREMENT)
+);
+
+INSERT INTO MimeType(MimeTypeId, MimeTypeCode, MimeTypeName)
+SELECT 1, '.jpeg', 'image/jpeg' UNION
+SELECT 2, '.jpg','image/jpeg' UNION
+SELECT 3, '.png','image/png' UNION
+SELECT 4, '.bmp','image/bmp' UNION
+SELECT 5, '.gif','image/gif' UNION
+SELECT 6, '.tif','image/tiff' UNION
+SELECT 7, '.tiff','image/tiff' UNION
+SELECT 8, '.xml','text/xml' UNION
+SELECT 9, '.txt','text/plain' UNION
+SELECT 10, '.json','application/json';
\ No newline at end of file
diff --git a/test/NDB.Test.Application/Scripts/1.0.1/04.Create table Settings.sql b/test/NDB.Test.Application/Scripts/1.0.1/04.Create table Settings.sql
new file mode 100644
index 0000000..40d5c0b
--- /dev/null
+++ b/test/NDB.Test.Application/Scripts/1.0.1/04.Create table Settings.sql
@@ -0,0 +1,13 @@
+CREATE TABLE "Settings" (
+ "Id" INTEGER NOT NULL,
+ "Code" TEXT NOT NULL UNIQUE,
+ "Name" TEXT NOT NULL,
+ "Description" TEXT,
+ "Context" TEXT NOT NULL
+ CONSTRAINT "PK_Settings" PRIMARY KEY("Id" AUTOINCREMENT)
+);
+
+INSERT INTO Settings(Id, Code, Name, Context)
+SELECT 1, 'THEME', 'Application theme', 'USER' UNION
+SELECT 2, 'LANGUAGE', 'Application language', 'USER' UNION
+SELECT 3, 'NOTIFICATIONS_POSITION', 'Notifications position', 'USER'
\ No newline at end of file