Added NDB.Infrastructure.DatabaseMigration
parent
3228609fcb
commit
179074260e
|
@ -13,5 +13,6 @@
|
||||||
<NDBExtensionsSwaggerPackageVersion>1.0.2</NDBExtensionsSwaggerPackageVersion>
|
<NDBExtensionsSwaggerPackageVersion>1.0.2</NDBExtensionsSwaggerPackageVersion>
|
||||||
<NDBApplicationPackageVersion>1.0.0</NDBApplicationPackageVersion>
|
<NDBApplicationPackageVersion>1.0.0</NDBApplicationPackageVersion>
|
||||||
<NDBSecurityAuthenticationPackageVersion>1.0.7</NDBSecurityAuthenticationPackageVersion>
|
<NDBSecurityAuthenticationPackageVersion>1.0.7</NDBSecurityAuthenticationPackageVersion>
|
||||||
|
<NDBDatabaseMigrationPackageVersion>1.0.2</NDBDatabaseMigrationPackageVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -12,4 +12,28 @@
|
||||||
<ProjectReference Include="..\NetworkResurrector.Api.Domain\NetworkResurrector.Api.Domain.csproj" />
|
<ProjectReference Include="..\NetworkResurrector.Api.Domain\NetworkResurrector.Api.Domain.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="Scripts\1.0.0\01.Machine table.sql">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Scripts\1.0.1\01.Added RPi machines.sql">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Scripts\1.0.1\02.Added new RPi machines.sql">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Scripts\1.0.2\01.Add ***REMOVED*** machine.sql">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Scripts\1.0.3\01.Power actions configuration.sql">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Scripts\1.0.3\02.Insert wake and ping configs for the rest of machines.sql">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Scripts\1.0.3\03.Register Acer thin testing machine.sql">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -10,7 +10,6 @@ begin
|
||||||
[Description] varchar(max)
|
[Description] varchar(max)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
go
|
|
||||||
|
|
||||||
if not exists (select top 1 1 from Machine)
|
if not exists (select top 1 1 from Machine)
|
||||||
begin
|
begin
|
||||||
|
@ -21,5 +20,4 @@ begin
|
||||||
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', 'Proxmox node' union
|
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', 'Proxmox node' union
|
||||||
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', 'VMware ESXi Hypervisor' union
|
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', 'VMware ESXi Hypervisor' union
|
||||||
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', 'OpenMediaVault Server'
|
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', 'OpenMediaVault Server'
|
||||||
end
|
end
|
||||||
go
|
|
|
@ -3,11 +3,9 @@ begin
|
||||||
insert into Machine(MachineName, FullMachineName, MACAddress, IPv4Address, [Description])
|
insert into Machine(MachineName, FullMachineName, MACAddress, IPv4Address, [Description])
|
||||||
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', 'Raspberry Pi 3 Model B server'
|
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', 'Raspberry Pi 3 Model B server'
|
||||||
end
|
end
|
||||||
go
|
|
||||||
|
|
||||||
if not exists (select top 1 1 from Machine where MachineName = '***REMOVED***')
|
if not exists (select top 1 1 from Machine where MachineName = '***REMOVED***')
|
||||||
begin
|
begin
|
||||||
insert into Machine(MachineName, FullMachineName, MACAddress, IPv4Address, [Description])
|
insert into Machine(MachineName, FullMachineName, MACAddress, IPv4Address, [Description])
|
||||||
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', 'Raspberry Pi 2 Model B server'
|
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', 'Raspberry Pi 2 Model B server'
|
||||||
end
|
end
|
||||||
go
|
|
|
@ -3,11 +3,9 @@ begin
|
||||||
insert into Machine(MachineName, FullMachineName, MACAddress, IPv4Address, [Description])
|
insert into Machine(MachineName, FullMachineName, MACAddress, IPv4Address, [Description])
|
||||||
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', 'Raspberry Pi 4 Model B/8GB'
|
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', 'Raspberry Pi 4 Model B/8GB'
|
||||||
end
|
end
|
||||||
go
|
|
||||||
|
|
||||||
if not exists (select top 1 1 from Machine where MachineName = '***REMOVED***')
|
if not exists (select top 1 1 from Machine where MachineName = '***REMOVED***')
|
||||||
begin
|
begin
|
||||||
insert into Machine(MachineName, FullMachineName, MACAddress, IPv4Address, [Description])
|
insert into Machine(MachineName, FullMachineName, MACAddress, IPv4Address, [Description])
|
||||||
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', 'Raspberry Pi Zero W'
|
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', 'Raspberry Pi Zero W'
|
||||||
end
|
end
|
||||||
go
|
|
|
@ -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
|
|
@ -7,7 +7,6 @@ begin
|
||||||
PowerActionName varchar(130)
|
PowerActionName varchar(130)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
go
|
|
||||||
|
|
||||||
if not exists (select top 1 1 from PowerAction)
|
if not exists (select top 1 1 from PowerAction)
|
||||||
begin
|
begin
|
||||||
|
@ -26,7 +25,6 @@ begin
|
||||||
insert into PowerAction (PowerActionCode, PowerActionName)
|
insert into PowerAction (PowerActionCode, PowerActionName)
|
||||||
select 'LOCK', 'Lock machine user screen'
|
select 'LOCK', 'Lock machine user screen'
|
||||||
end
|
end
|
||||||
go
|
|
||||||
|
|
||||||
if not exists (select top 1 1 from sys.objects where name = 'PowerActionPerformer' and type = 'U')
|
if not exists (select top 1 1 from sys.objects where name = 'PowerActionPerformer' and type = 'U')
|
||||||
begin
|
begin
|
||||||
|
@ -37,7 +35,6 @@ begin
|
||||||
PerformerName varchar(130)
|
PerformerName varchar(130)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
go
|
|
||||||
|
|
||||||
if not exists (select top 1 1 from PowerActionPerformer)
|
if not exists (select top 1 1 from PowerActionPerformer)
|
||||||
begin
|
begin
|
||||||
|
@ -55,7 +52,6 @@ begin
|
||||||
constraint FK_MachineAgent_Machine foreign key (MachineId) references Machine(MachineId)
|
constraint FK_MachineAgent_Machine foreign key (MachineId) references Machine(MachineId)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
go
|
|
||||||
|
|
||||||
if not exists (select top 1 1 from sys.objects where name = 'PowerActionConfiguration' and type = 'U')
|
if not exists (select top 1 1 from sys.objects where name = 'PowerActionConfiguration' and type = 'U')
|
||||||
begin
|
begin
|
||||||
|
@ -67,7 +63,6 @@ begin
|
||||||
PerformerId int constraint FK_PowerActionConfiguration_PowerActionPerformer foreign key references PowerActionPerformer(PerformerId)
|
PerformerId int constraint FK_PowerActionConfiguration_PowerActionPerformer foreign key references PowerActionPerformer(PerformerId)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
go
|
|
||||||
|
|
||||||
declare @orion_machine_id int, @server_performer_id int, @agent_performer_id int
|
declare @orion_machine_id int, @server_performer_id int, @agent_performer_id int
|
||||||
select @orion_machine_id = MachineId from Machine where MachineName = '***REMOVED***'
|
select @orion_machine_id = MachineId from Machine where MachineName = '***REMOVED***'
|
||||||
|
@ -89,5 +84,4 @@ begin
|
||||||
else @agent_performer_id
|
else @agent_performer_id
|
||||||
end
|
end
|
||||||
from PowerAction
|
from PowerAction
|
||||||
end
|
end
|
||||||
go
|
|
|
@ -3,7 +3,6 @@ begin
|
||||||
insert into Machine(MachineName, FullMachineName, MACAddress, IPv4Address, [Description])
|
insert into Machine(MachineName, FullMachineName, MACAddress, IPv4Address, [Description])
|
||||||
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED*** - Acer thin testing machine'
|
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED*** - Acer thin testing machine'
|
||||||
end
|
end
|
||||||
go
|
|
||||||
|
|
||||||
declare @machine_id int, @server_performer_id int, @agent_performer_id int
|
declare @machine_id int, @server_performer_id int, @agent_performer_id int
|
||||||
select @machine_id = MachineId from Machine where MachineName = '***REMOVED***'
|
select @machine_id = MachineId from Machine where MachineName = '***REMOVED***'
|
||||||
|
@ -25,5 +24,4 @@ begin
|
||||||
else @agent_performer_id
|
else @agent_performer_id
|
||||||
end
|
end
|
||||||
from PowerAction
|
from PowerAction
|
||||||
end
|
end
|
||||||
go
|
|
|
@ -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')
|
if not exists (select top 1 1 from sys.objects where name = 'ActivityLog' and type = 'U')
|
||||||
begin
|
begin
|
||||||
create table ActivityLog
|
create table ActivityLog
|
||||||
|
@ -23,7 +5,7 @@ begin
|
||||||
ActivityLogId int identity(1, 1) constraint PK_ActivityLog primary key,
|
ActivityLogId int identity(1, 1) constraint PK_ActivityLog primary key,
|
||||||
MachineId int constraint FK_ActivityLog_Machine foreign key references Machine(MachineId),
|
MachineId int constraint FK_ActivityLog_Machine foreign key references Machine(MachineId),
|
||||||
UserId int not null,
|
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,
|
ActivityDate datetime not null,
|
||||||
Success bit not null,
|
Success bit not null,
|
||||||
Details varchar(2000)
|
Details varchar(2000)
|
||||||
|
@ -36,7 +18,7 @@ begin
|
||||||
create table MachineCounters
|
create table MachineCounters
|
||||||
(
|
(
|
||||||
MachineId int constraint FK_MachineCounters_Machine foreign key references Machine(MachineId),
|
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
|
[Counter] int not null
|
||||||
)
|
)
|
||||||
end
|
end
|
|
@ -12,6 +12,7 @@
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="$(MicrosoftExtensionsPackageVersion)" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="$(MicrosoftExtensionsPackageVersion)" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="$(MicrosoftExtensionsPackageVersion)" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="$(MicrosoftExtensionsPackageVersion)" />
|
||||||
<PackageReference Include="NDB.Extensions.Swagger" Version="$(NDBExtensionsSwaggerPackageVersion)" />
|
<PackageReference Include="NDB.Extensions.Swagger" Version="$(NDBExtensionsSwaggerPackageVersion)" />
|
||||||
|
<PackageReference Include="NDB.Infrastructure.DatabaseMigration" Version="$(NDBDatabaseMigrationPackageVersion)" />
|
||||||
<PackageReference Include="NDB.Security.Authentication.Identity" Version="$(NDBSecurityAuthenticationPackageVersion)" />
|
<PackageReference Include="NDB.Security.Authentication.Identity" Version="$(NDBSecurityAuthenticationPackageVersion)" />
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="$(SerilogPackageVersion)" />
|
<PackageReference Include="Serilog.AspNetCore" Version="$(SerilogPackageVersion)" />
|
||||||
<PackageReference Include="Serilog.Extensions.Logging" Version="$(SerilogExtensionsPackageVersion)" />
|
<PackageReference Include="Serilog.Extensions.Logging" Version="$(SerilogExtensionsPackageVersion)" />
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace NetworkResurrector.Api
|
||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
var isConsole = Debugger.IsAttached || args.Contains("--console");
|
var isConsole = args.Contains("--console");
|
||||||
if (!isConsole)
|
if (!isConsole)
|
||||||
{
|
{
|
||||||
var pathToExe = Process.GetCurrentProcess().MainModule.FileName;
|
var pathToExe = Process.GetCurrentProcess().MainModule.FileName;
|
||||||
|
|
|
@ -6,6 +6,8 @@ using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using NDB.Extensions.Swagger;
|
using NDB.Extensions.Swagger;
|
||||||
using NDB.Extensions.Swagger.Constants;
|
using NDB.Extensions.Swagger.Constants;
|
||||||
|
using NDB.Infrastructure.DatabaseMigration;
|
||||||
|
using NDB.Infrastructure.DatabaseMigration.Constants;
|
||||||
using NDB.Security.Authentication.Identity;
|
using NDB.Security.Authentication.Identity;
|
||||||
using NetworkResurrector.Agent.Wrapper;
|
using NetworkResurrector.Agent.Wrapper;
|
||||||
using NetworkResurrector.Api.Application;
|
using NetworkResurrector.Api.Application;
|
||||||
|
@ -57,6 +59,7 @@ namespace NetworkResurrector.Api
|
||||||
services.UseResurrectorAgentServices();
|
services.UseResurrectorAgentServices();
|
||||||
|
|
||||||
// Data access
|
// Data access
|
||||||
|
services.AddMigration(DatabaseType.SQLServer);
|
||||||
services.AddDataAccess();
|
services.AddDataAccess();
|
||||||
|
|
||||||
// Application
|
// Application
|
||||||
|
@ -84,6 +87,8 @@ namespace NetworkResurrector.Api
|
||||||
endpoints.MapControllers();
|
endpoints.MapControllers();
|
||||||
});
|
});
|
||||||
app.ConfigureSwagger("NetworkResurrector API");
|
app.ConfigureSwagger("NetworkResurrector API");
|
||||||
|
|
||||||
|
app.UseMigration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"urls": "http://*:5064",
|
"urls": "http://*:5064",
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
//"DatabaseConnection": "***REMOVED***"
|
|
||||||
//"DatabaseConnection": "***REMOVED***"
|
|
||||||
"DatabaseConnection": "***REMOVED***"
|
"DatabaseConnection": "***REMOVED***"
|
||||||
|
//"DatabaseConnection": "***REMOVED***"
|
||||||
|
//"DatabaseConnection": "***REMOVED***"
|
||||||
},
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
|
|
Loading…
Reference in New Issue