diff --git a/dependencies.props b/dependencies.props
index 1614ffa..88a638c 100644
--- a/dependencies.props
+++ b/dependencies.props
@@ -13,5 +13,6 @@
1.0.2
1.0.0
1.0.7
+ 1.0.2
\ No newline at end of file
diff --git a/src/api/NetworkResurrector.Api.Domain.Data/NetworkResurrector.Api.Domain.Data.csproj b/src/api/NetworkResurrector.Api.Domain.Data/NetworkResurrector.Api.Domain.Data.csproj
index 55f2fad..66143a6 100644
--- a/src/api/NetworkResurrector.Api.Domain.Data/NetworkResurrector.Api.Domain.Data.csproj
+++ b/src/api/NetworkResurrector.Api.Domain.Data/NetworkResurrector.Api.Domain.Data.csproj
@@ -12,4 +12,28 @@
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+
diff --git a/src/api/NetworkResurrector.Api.Domain.Data/Scripts/001.Machine table.sql b/src/api/NetworkResurrector.Api.Domain.Data/Scripts/1.0.0/01.Machine table.sql
similarity index 99%
rename from src/api/NetworkResurrector.Api.Domain.Data/Scripts/001.Machine table.sql
rename to src/api/NetworkResurrector.Api.Domain.Data/Scripts/1.0.0/01.Machine table.sql
index 6708353..744d7a3 100644
--- a/src/api/NetworkResurrector.Api.Domain.Data/Scripts/001.Machine table.sql
+++ b/src/api/NetworkResurrector.Api.Domain.Data/Scripts/1.0.0/01.Machine table.sql
@@ -10,7 +10,6 @@ begin
[Description] varchar(max)
)
end
-go
if not exists (select top 1 1 from Machine)
begin
@@ -21,5 +20,4 @@ begin
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', 'Proxmox node' union
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', 'VMware ESXi Hypervisor' union
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', 'OpenMediaVault Server'
-end
-go
\ No newline at end of file
+end
\ No newline at end of file
diff --git a/src/api/NetworkResurrector.Api.Domain.Data/Scripts/003.Added RPi machines.sql b/src/api/NetworkResurrector.Api.Domain.Data/Scripts/1.0.1/01.Added RPi machines.sql
similarity index 98%
rename from src/api/NetworkResurrector.Api.Domain.Data/Scripts/003.Added RPi machines.sql
rename to src/api/NetworkResurrector.Api.Domain.Data/Scripts/1.0.1/01.Added RPi machines.sql
index 83fa3c2..67f0633 100644
--- a/src/api/NetworkResurrector.Api.Domain.Data/Scripts/003.Added RPi machines.sql
+++ b/src/api/NetworkResurrector.Api.Domain.Data/Scripts/1.0.1/01.Added RPi machines.sql
@@ -3,11 +3,9 @@ begin
insert into Machine(MachineName, FullMachineName, MACAddress, IPv4Address, [Description])
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', 'Raspberry Pi 3 Model B server'
end
-go
if not exists (select top 1 1 from Machine where MachineName = '***REMOVED***')
begin
insert into Machine(MachineName, FullMachineName, MACAddress, IPv4Address, [Description])
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', 'Raspberry Pi 2 Model B server'
-end
-go
\ No newline at end of file
+end
\ No newline at end of file
diff --git a/src/api/NetworkResurrector.Api.Domain.Data/Scripts/004.Added new RPi machines.sql b/src/api/NetworkResurrector.Api.Domain.Data/Scripts/1.0.1/02.Added new RPi machines.sql
similarity index 98%
rename from src/api/NetworkResurrector.Api.Domain.Data/Scripts/004.Added new RPi machines.sql
rename to src/api/NetworkResurrector.Api.Domain.Data/Scripts/1.0.1/02.Added new RPi machines.sql
index 86072ee..a25f79a 100644
--- a/src/api/NetworkResurrector.Api.Domain.Data/Scripts/004.Added new RPi machines.sql
+++ b/src/api/NetworkResurrector.Api.Domain.Data/Scripts/1.0.1/02.Added new RPi machines.sql
@@ -3,11 +3,9 @@ begin
insert into Machine(MachineName, FullMachineName, MACAddress, IPv4Address, [Description])
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', 'Raspberry Pi 4 Model B/8GB'
end
-go
if not exists (select top 1 1 from Machine where MachineName = '***REMOVED***')
begin
insert into Machine(MachineName, FullMachineName, MACAddress, IPv4Address, [Description])
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', 'Raspberry Pi Zero W'
-end
-go
\ No newline at end of file
+end
\ No newline at end of file
diff --git a/src/api/NetworkResurrector.Api.Domain.Data/Scripts/1.0.2/01.Add pve-master machine.sql b/src/api/NetworkResurrector.Api.Domain.Data/Scripts/1.0.2/01.Add pve-master machine.sql
new file mode 100644
index 0000000..4426a08
--- /dev/null
+++ b/src/api/NetworkResurrector.Api.Domain.Data/Scripts/1.0.2/01.Add pve-master machine.sql
@@ -0,0 +1,5 @@
+if not exists (select top 1 1 from Machine where MachineName = '***REMOVED***')
+begin
+ insert into Machine(MachineName, FullMachineName, MACAddress, IPv4Address, [Description])
+ select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', 'Proxmox main node'
+end
\ No newline at end of file
diff --git a/src/api/NetworkResurrector.Api.Domain.Data/Scripts/005.Power actions configuration.sql b/src/api/NetworkResurrector.Api.Domain.Data/Scripts/1.0.3/01.Power actions configuration.sql
similarity index 99%
rename from src/api/NetworkResurrector.Api.Domain.Data/Scripts/005.Power actions configuration.sql
rename to src/api/NetworkResurrector.Api.Domain.Data/Scripts/1.0.3/01.Power actions configuration.sql
index 16cf933..fbec6d3 100644
--- a/src/api/NetworkResurrector.Api.Domain.Data/Scripts/005.Power actions configuration.sql
+++ b/src/api/NetworkResurrector.Api.Domain.Data/Scripts/1.0.3/01.Power actions configuration.sql
@@ -7,7 +7,6 @@ begin
PowerActionName varchar(130)
)
end
-go
if not exists (select top 1 1 from PowerAction)
begin
@@ -26,7 +25,6 @@ begin
insert into PowerAction (PowerActionCode, PowerActionName)
select 'LOCK', 'Lock machine user screen'
end
-go
if not exists (select top 1 1 from sys.objects where name = 'PowerActionPerformer' and type = 'U')
begin
@@ -37,7 +35,6 @@ begin
PerformerName varchar(130)
)
end
-go
if not exists (select top 1 1 from PowerActionPerformer)
begin
@@ -55,7 +52,6 @@ begin
constraint FK_MachineAgent_Machine foreign key (MachineId) references Machine(MachineId)
)
end
-go
if not exists (select top 1 1 from sys.objects where name = 'PowerActionConfiguration' and type = 'U')
begin
@@ -67,7 +63,6 @@ begin
PerformerId int constraint FK_PowerActionConfiguration_PowerActionPerformer foreign key references PowerActionPerformer(PerformerId)
)
end
-go
declare @orion_machine_id int, @server_performer_id int, @agent_performer_id int
select @orion_machine_id = MachineId from Machine where MachineName = '***REMOVED***'
@@ -89,5 +84,4 @@ begin
else @agent_performer_id
end
from PowerAction
-end
-go
\ No newline at end of file
+end
\ No newline at end of file
diff --git a/src/api/NetworkResurrector.Api.Domain.Data/Scripts/006.Insert wake and ping configs for the rest of machines.sql b/src/api/NetworkResurrector.Api.Domain.Data/Scripts/1.0.3/02.Insert wake and ping configs for the rest of machines.sql
similarity index 100%
rename from src/api/NetworkResurrector.Api.Domain.Data/Scripts/006.Insert wake and ping configs for the rest of machines.sql
rename to src/api/NetworkResurrector.Api.Domain.Data/Scripts/1.0.3/02.Insert wake and ping configs for the rest of machines.sql
diff --git a/src/api/NetworkResurrector.Api.Domain.Data/Scripts/007.Register Acer thin testing machine.sql b/src/api/NetworkResurrector.Api.Domain.Data/Scripts/1.0.3/03.Register Acer thin testing machine.sql
similarity index 99%
rename from src/api/NetworkResurrector.Api.Domain.Data/Scripts/007.Register Acer thin testing machine.sql
rename to src/api/NetworkResurrector.Api.Domain.Data/Scripts/1.0.3/03.Register Acer thin testing machine.sql
index 290d3aa..1008998 100644
--- a/src/api/NetworkResurrector.Api.Domain.Data/Scripts/007.Register Acer thin testing machine.sql
+++ b/src/api/NetworkResurrector.Api.Domain.Data/Scripts/1.0.3/03.Register Acer thin testing machine.sql
@@ -3,7 +3,6 @@ begin
insert into Machine(MachineName, FullMachineName, MACAddress, IPv4Address, [Description])
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED*** - Acer thin testing machine'
end
-go
declare @machine_id int, @server_performer_id int, @agent_performer_id int
select @machine_id = MachineId from Machine where MachineName = '***REMOVED***'
@@ -25,5 +24,4 @@ begin
else @agent_performer_id
end
from PowerAction
-end
-go
\ No newline at end of file
+end
\ No newline at end of file
diff --git a/src/api/NetworkResurrector.Api.Domain.Data/Scripts/002.Activity tables.sql b/src/api/NetworkResurrector.Api.Domain.Data/Scripts/1.0.4/01.Activity tables.sql
similarity index 51%
rename from src/api/NetworkResurrector.Api.Domain.Data/Scripts/002.Activity tables.sql
rename to src/api/NetworkResurrector.Api.Domain.Data/Scripts/1.0.4/01.Activity tables.sql
index 56fd423..5c119d7 100644
--- a/src/api/NetworkResurrector.Api.Domain.Data/Scripts/002.Activity tables.sql
+++ b/src/api/NetworkResurrector.Api.Domain.Data/Scripts/1.0.4/01.Activity tables.sql
@@ -1,21 +1,3 @@
-if not exists (select top 1 1 from sys.objects where name = 'Activity' and type = 'U')
-begin
- create table Activity
- (
- ActivityId int identity(1, 1) constraint PK_Activity primary key,
- ActivityCode varchar(30),
- ActivityName varchar(130)
- )
-end
-go
-
-if not exists (select top 1 1 from Activity)
-begin
- insert into Activity (ActivityCode, ActivityName)
- select 'WAKE', 'Wake machine' union
- select 'PING', 'Ping machine'
-end
-
if not exists (select top 1 1 from sys.objects where name = 'ActivityLog' and type = 'U')
begin
create table ActivityLog
@@ -23,7 +5,7 @@ begin
ActivityLogId int identity(1, 1) constraint PK_ActivityLog primary key,
MachineId int constraint FK_ActivityLog_Machine foreign key references Machine(MachineId),
UserId int not null,
- ActivityId int constraint FK_ActivityLog_Activity foreign key references Activity(ActivityId),
+ ActivityId int constraint FK_ActivityLog_PowerAction foreign key references PowerAction(PowerActionId),
ActivityDate datetime not null,
Success bit not null,
Details varchar(2000)
@@ -36,7 +18,7 @@ begin
create table MachineCounters
(
MachineId int constraint FK_MachineCounters_Machine foreign key references Machine(MachineId),
- ActivityId int constraint FK_MachineCounters_Activity foreign key references Activity(ActivityId),
+ ActivityId int constraint FK_MachineCounters_PowerAction foreign key references PowerAction(PowerActionId),
[Counter] int not null
)
end
diff --git a/src/api/NetworkResurrector.Api/NetworkResurrector.Api.csproj b/src/api/NetworkResurrector.Api/NetworkResurrector.Api.csproj
index 01aa293..a4ab6ca 100644
--- a/src/api/NetworkResurrector.Api/NetworkResurrector.Api.csproj
+++ b/src/api/NetworkResurrector.Api/NetworkResurrector.Api.csproj
@@ -12,6 +12,7 @@
+
diff --git a/src/api/NetworkResurrector.Api/Program.cs b/src/api/NetworkResurrector.Api/Program.cs
index 7cbc16c..39f4032 100644
--- a/src/api/NetworkResurrector.Api/Program.cs
+++ b/src/api/NetworkResurrector.Api/Program.cs
@@ -16,7 +16,7 @@ namespace NetworkResurrector.Api
{
public static void Main(string[] args)
{
- var isConsole = Debugger.IsAttached || args.Contains("--console");
+ var isConsole = args.Contains("--console");
if (!isConsole)
{
var pathToExe = Process.GetCurrentProcess().MainModule.FileName;
diff --git a/src/api/NetworkResurrector.Api/Startup.cs b/src/api/NetworkResurrector.Api/Startup.cs
index b4e0455..b880e1e 100644
--- a/src/api/NetworkResurrector.Api/Startup.cs
+++ b/src/api/NetworkResurrector.Api/Startup.cs
@@ -6,6 +6,8 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using NDB.Extensions.Swagger;
using NDB.Extensions.Swagger.Constants;
+using NDB.Infrastructure.DatabaseMigration;
+using NDB.Infrastructure.DatabaseMigration.Constants;
using NDB.Security.Authentication.Identity;
using NetworkResurrector.Agent.Wrapper;
using NetworkResurrector.Api.Application;
@@ -57,6 +59,7 @@ namespace NetworkResurrector.Api
services.UseResurrectorAgentServices();
// Data access
+ services.AddMigration(DatabaseType.SQLServer);
services.AddDataAccess();
// Application
@@ -84,6 +87,8 @@ namespace NetworkResurrector.Api
endpoints.MapControllers();
});
app.ConfigureSwagger("NetworkResurrector API");
+
+ app.UseMigration();
}
}
}
diff --git a/src/api/NetworkResurrector.Api/appsettings.json b/src/api/NetworkResurrector.Api/appsettings.json
index 8488344..52deb72 100644
--- a/src/api/NetworkResurrector.Api/appsettings.json
+++ b/src/api/NetworkResurrector.Api/appsettings.json
@@ -1,9 +1,9 @@
{
"urls": "http://*:5064",
"ConnectionStrings": {
- //"DatabaseConnection": "***REMOVED***"
- //"DatabaseConnection": "***REMOVED***"
"DatabaseConnection": "***REMOVED***"
+ //"DatabaseConnection": "***REMOVED***"
+ //"DatabaseConnection": "***REMOVED***"
},
"Logging": {
"LogLevel": {