Added NDB.Infrastructure.DatabaseMigration
parent
3228609fcb
commit
179074260e
|
@ -13,5 +13,6 @@
|
|||
<NDBExtensionsSwaggerPackageVersion>1.0.2</NDBExtensionsSwaggerPackageVersion>
|
||||
<NDBApplicationPackageVersion>1.0.0</NDBApplicationPackageVersion>
|
||||
<NDBSecurityAuthenticationPackageVersion>1.0.7</NDBSecurityAuthenticationPackageVersion>
|
||||
<NDBDatabaseMigrationPackageVersion>1.0.2</NDBDatabaseMigrationPackageVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -12,4 +12,28 @@
|
|||
<ProjectReference Include="..\NetworkResurrector.Api.Domain\NetworkResurrector.Api.Domain.csproj" />
|
||||
</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>
|
||||
|
|
|
@ -10,7 +10,6 @@ begin
|
|||
[Description] varchar(max)
|
||||
)
|
||||
end
|
||||
go
|
||||
|
||||
if not exists (select top 1 1 from Machine)
|
||||
begin
|
||||
|
@ -22,4 +21,3 @@ begin
|
|||
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', 'VMware ESXi Hypervisor' union
|
||||
select '***REMOVED***', '***REMOVED***', '***REMOVED***', '***REMOVED***', 'OpenMediaVault Server'
|
||||
end
|
||||
go
|
|
@ -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
|
|
@ -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
|
|
@ -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)
|
||||
)
|
||||
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***'
|
||||
|
@ -90,4 +85,3 @@ begin
|
|||
end
|
||||
from PowerAction
|
||||
end
|
||||
go
|
|
@ -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***'
|
||||
|
@ -26,4 +25,3 @@ begin
|
|||
end
|
||||
from PowerAction
|
||||
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')
|
||||
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
|
|
@ -12,6 +12,7 @@
|
|||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="$(MicrosoftExtensionsPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="$(MicrosoftExtensionsPackageVersion)" />
|
||||
<PackageReference Include="NDB.Extensions.Swagger" Version="$(NDBExtensionsSwaggerPackageVersion)" />
|
||||
<PackageReference Include="NDB.Infrastructure.DatabaseMigration" Version="$(NDBDatabaseMigrationPackageVersion)" />
|
||||
<PackageReference Include="NDB.Security.Authentication.Identity" Version="$(NDBSecurityAuthenticationPackageVersion)" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="$(SerilogPackageVersion)" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="$(SerilogExtensionsPackageVersion)" />
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"urls": "http://*:5064",
|
||||
"ConnectionStrings": {
|
||||
//"DatabaseConnection": "***REMOVED***"
|
||||
//"DatabaseConnection": "***REMOVED***"
|
||||
"DatabaseConnection": "***REMOVED***"
|
||||
//"DatabaseConnection": "***REMOVED***"
|
||||
//"DatabaseConnection": "***REMOVED***"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
|
|
Loading…
Reference in New Issue