Added database entities, started with node crud
This commit is contained in:
12
MoonlightServers.ApiServer/Database/Entities/Allocation.cs
Normal file
12
MoonlightServers.ApiServer/Database/Entities/Allocation.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
namespace MoonlightServers.ApiServer.Database.Entities;
|
||||||
|
|
||||||
|
public class Allocation
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string IpAddress { get; set; } = "0.0.0.0";
|
||||||
|
public int Port { get; set; }
|
||||||
|
|
||||||
|
public Server? Server { get; set; }
|
||||||
|
public Node Node { get; set; }
|
||||||
|
}
|
||||||
18
MoonlightServers.ApiServer/Database/Entities/Backup.cs
Normal file
18
MoonlightServers.ApiServer/Database/Entities/Backup.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using MoonlightServers.Shared.Enums;
|
||||||
|
|
||||||
|
namespace MoonlightServers.ApiServer.Database.Entities;
|
||||||
|
|
||||||
|
public class Backup
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
public BackupState State { get; set; }
|
||||||
|
|
||||||
|
public long Size { get; set; }
|
||||||
|
|
||||||
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||||
|
public DateTime FinishedAt { get; set; } = DateTime.UtcNow;
|
||||||
|
|
||||||
|
public Server Server { get; set; }
|
||||||
|
}
|
||||||
11
MoonlightServers.ApiServer/Database/Entities/Network.cs
Normal file
11
MoonlightServers.ApiServer/Database/Entities/Network.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
namespace MoonlightServers.ApiServer.Database.Entities;
|
||||||
|
|
||||||
|
public class Network
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public Node Node { get; set; }
|
||||||
|
public List<Server> Servers { get; set; } = new();
|
||||||
|
}
|
||||||
16
MoonlightServers.ApiServer/Database/Entities/Node.cs
Normal file
16
MoonlightServers.ApiServer/Database/Entities/Node.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
namespace MoonlightServers.ApiServer.Database.Entities;
|
||||||
|
|
||||||
|
public class Node
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public string Fqdn { get; set; }
|
||||||
|
public int ApiPort { get; set; }
|
||||||
|
public string Token { get; set; }
|
||||||
|
public bool SslEnabled { get; set; }
|
||||||
|
|
||||||
|
public List<Allocation> Allocations { get; set; } = new();
|
||||||
|
public List<Server> Servers { get; set; } = new();
|
||||||
|
}
|
||||||
26
MoonlightServers.ApiServer/Database/Entities/Server.cs
Normal file
26
MoonlightServers.ApiServer/Database/Entities/Server.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
namespace MoonlightServers.ApiServer.Database.Entities;
|
||||||
|
|
||||||
|
public class Server
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public int Cpu { get; set; }
|
||||||
|
public int Memory { get; set; }
|
||||||
|
public int Disk { get; set; }
|
||||||
|
|
||||||
|
public string? OverrideStartupCommand { get; set; } = null;
|
||||||
|
public string? OverrideDockerImage { get; set; } = null;
|
||||||
|
|
||||||
|
public bool VirtualDiskEnabled { get; set; } = false;
|
||||||
|
|
||||||
|
public Star Star { get; set; }
|
||||||
|
public int DockerImageIndex { get; set; } = 0;
|
||||||
|
|
||||||
|
public Node Node { get; set; }
|
||||||
|
public Network? Network { get; set; }
|
||||||
|
public List<Allocation> Allocations { get; set; } = new();
|
||||||
|
public List<ServerVariable> Variables { get; set; } = new();
|
||||||
|
public List<Backup> Backups { get; set; } = new();
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
namespace MoonlightServers.ApiServer.Database.Entities;
|
||||||
|
|
||||||
|
public class ServerVariable
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string Key { get; set; }
|
||||||
|
public string Value { get; set; }
|
||||||
|
|
||||||
|
public Server Server { get; set; }
|
||||||
|
}
|
||||||
31
MoonlightServers.ApiServer/Database/Entities/Star.cs
Normal file
31
MoonlightServers.ApiServer/Database/Entities/Star.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
namespace MoonlightServers.ApiServer.Database.Entities;
|
||||||
|
|
||||||
|
public class Star
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Author { get; set; }
|
||||||
|
|
||||||
|
public string? DonationUrl { get; set; }
|
||||||
|
public string? UpdateUrl { get; set; }
|
||||||
|
|
||||||
|
public string StartupCommand { get; set; }
|
||||||
|
public string StopCommand { get; set; }
|
||||||
|
public string OnlineDetection { get; set; }
|
||||||
|
|
||||||
|
public string InstallShell { get; set; }
|
||||||
|
public string InstallDockerImage { get; set; }
|
||||||
|
public string InstallScript { get; set; }
|
||||||
|
public int RequiredAllocations { get; set; }
|
||||||
|
|
||||||
|
public string ParseConfiguration { get; set; }
|
||||||
|
|
||||||
|
public int DefaultDockerImageIndex { get; set; }
|
||||||
|
public bool AllowDockerImageChanging { get; set; }
|
||||||
|
|
||||||
|
public List<StarVariable> Variables { get; set; } = new();
|
||||||
|
public List<StarDockerImage> DockerImages { get; set; } = new();
|
||||||
|
|
||||||
|
public StarFolder? Folder { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
namespace MoonlightServers.ApiServer.Database.Entities;
|
||||||
|
|
||||||
|
public class StarDockerImage
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string Identifier { get; set; }
|
||||||
|
public string DisplayName { get; set; }
|
||||||
|
|
||||||
|
public bool AutoPulling { get; set; } = true;
|
||||||
|
}
|
||||||
10
MoonlightServers.ApiServer/Database/Entities/StarFolder.cs
Normal file
10
MoonlightServers.ApiServer/Database/Entities/StarFolder.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
namespace MoonlightServers.ApiServer.Database.Entities;
|
||||||
|
|
||||||
|
public class StarFolder
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public List<Star> Stars { get; set; } = new();
|
||||||
|
}
|
||||||
20
MoonlightServers.ApiServer/Database/Entities/StarVariable.cs
Normal file
20
MoonlightServers.ApiServer/Database/Entities/StarVariable.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using MoonlightServers.Shared.Enums;
|
||||||
|
|
||||||
|
namespace MoonlightServers.ApiServer.Database.Entities;
|
||||||
|
|
||||||
|
public class StarVariable
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string Key { get; set; }
|
||||||
|
public string DefaultValue { get; set; }
|
||||||
|
|
||||||
|
public string DisplayName { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
public bool AllowViewing { get; set; } = false;
|
||||||
|
public bool AllowEditing { get; set; } = false;
|
||||||
|
|
||||||
|
public string? Filter { get; set; }
|
||||||
|
public StarVariableType Type { get; set; } = StarVariableType.Text;
|
||||||
|
}
|
||||||
519
MoonlightServers.ApiServer/Database/Migrations/20240830074359_AddedServerEntities.Designer.cs
generated
Normal file
519
MoonlightServers.ApiServer/Database/Migrations/20240830074359_AddedServerEntities.Designer.cs
generated
Normal file
@@ -0,0 +1,519 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using MoonlightServers.ApiServer.Database;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace MoonlightServers.ApiServer.Database.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(ServersContext))]
|
||||||
|
[Migration("20240830074359_AddedServerEntities")]
|
||||||
|
partial class AddedServerEntities
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasDefaultSchema("Servers")
|
||||||
|
.HasAnnotation("ProductVersion", "8.0.7")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||||
|
|
||||||
|
MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Allocation", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("IpAddress")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int>("NodeId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Port")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int?>("ServerId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NodeId");
|
||||||
|
|
||||||
|
b.HasIndex("ServerId");
|
||||||
|
|
||||||
|
b.ToTable("Allocations", "Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Backup", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.HasColumnType("datetime(6)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("FinishedAt")
|
||||||
|
.HasColumnType("datetime(6)");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int>("ServerId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<long>("Size")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<int>("State")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ServerId");
|
||||||
|
|
||||||
|
b.ToTable("Backups", "Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Network", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int>("NodeId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NodeId");
|
||||||
|
|
||||||
|
b.ToTable("Networks", "Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Node", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("ApiPort")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Fqdn")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<bool>("SslEnabled")
|
||||||
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
b.Property<string>("Token")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Nodes", "Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Server", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Cpu")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Disk")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("DockerImageIndex")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Memory")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int?>("NetworkId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("NodeId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("OverrideDockerImage")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("OverrideStartupCommand")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int>("StarId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<bool>("VirtualDiskEnabled")
|
||||||
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NetworkId");
|
||||||
|
|
||||||
|
b.HasIndex("NodeId");
|
||||||
|
|
||||||
|
b.HasIndex("StarId");
|
||||||
|
|
||||||
|
b.ToTable("Servers", "Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.ServerVariable", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Key")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int>("ServerId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ServerId");
|
||||||
|
|
||||||
|
b.ToTable("ServerVariables", "Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Star", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<bool>("AllowDockerImageChanging")
|
||||||
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
b.Property<string>("Author")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int>("DefaultDockerImageIndex")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("DonationUrl")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int?>("FolderId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("InstallDockerImage")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("InstallScript")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("InstallShell")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("OnlineDetection")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("ParseConfiguration")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int>("RequiredAllocations")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("StartupCommand")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("StopCommand")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("UpdateUrl")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("FolderId");
|
||||||
|
|
||||||
|
b.ToTable("Stars", "Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarDockerImage", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<bool>("AutoPulling")
|
||||||
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
b.Property<string>("DisplayName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("Identifier")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int?>("StarId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("StarId");
|
||||||
|
|
||||||
|
b.ToTable("StarDockerImages", "Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarFolder", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("StarFolders", "Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarVariable", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<bool>("AllowEditing")
|
||||||
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
b.Property<bool>("AllowViewing")
|
||||||
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
b.Property<string>("DefaultValue")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("DisplayName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("Filter")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("Key")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int?>("StarId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("StarId");
|
||||||
|
|
||||||
|
b.ToTable("StarVariables", "Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Allocation", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("MoonlightServers.ApiServer.Database.Entities.Node", "Node")
|
||||||
|
.WithMany("Allocations")
|
||||||
|
.HasForeignKey("NodeId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("MoonlightServers.ApiServer.Database.Entities.Server", "Server")
|
||||||
|
.WithMany("Allocations")
|
||||||
|
.HasForeignKey("ServerId");
|
||||||
|
|
||||||
|
b.Navigation("Node");
|
||||||
|
|
||||||
|
b.Navigation("Server");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Backup", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("MoonlightServers.ApiServer.Database.Entities.Server", "Server")
|
||||||
|
.WithMany("Backups")
|
||||||
|
.HasForeignKey("ServerId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Server");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Network", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("MoonlightServers.ApiServer.Database.Entities.Node", "Node")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("NodeId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Node");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Server", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("MoonlightServers.ApiServer.Database.Entities.Network", "Network")
|
||||||
|
.WithMany("Servers")
|
||||||
|
.HasForeignKey("NetworkId");
|
||||||
|
|
||||||
|
b.HasOne("MoonlightServers.ApiServer.Database.Entities.Node", "Node")
|
||||||
|
.WithMany("Servers")
|
||||||
|
.HasForeignKey("NodeId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("MoonlightServers.ApiServer.Database.Entities.Star", "Star")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("StarId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Network");
|
||||||
|
|
||||||
|
b.Navigation("Node");
|
||||||
|
|
||||||
|
b.Navigation("Star");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.ServerVariable", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("MoonlightServers.ApiServer.Database.Entities.Server", "Server")
|
||||||
|
.WithMany("Variables")
|
||||||
|
.HasForeignKey("ServerId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Server");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Star", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("MoonlightServers.ApiServer.Database.Entities.StarFolder", "Folder")
|
||||||
|
.WithMany("Stars")
|
||||||
|
.HasForeignKey("FolderId");
|
||||||
|
|
||||||
|
b.Navigation("Folder");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarDockerImage", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("MoonlightServers.ApiServer.Database.Entities.Star", null)
|
||||||
|
.WithMany("DockerImages")
|
||||||
|
.HasForeignKey("StarId");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarVariable", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("MoonlightServers.ApiServer.Database.Entities.Star", null)
|
||||||
|
.WithMany("Variables")
|
||||||
|
.HasForeignKey("StarId");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Network", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Node", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Allocations");
|
||||||
|
|
||||||
|
b.Navigation("Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Server", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Allocations");
|
||||||
|
|
||||||
|
b.Navigation("Backups");
|
||||||
|
|
||||||
|
b.Navigation("Variables");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Star", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("DockerImages");
|
||||||
|
|
||||||
|
b.Navigation("Variables");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarFolder", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Stars");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,434 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace MoonlightServers.ApiServer.Database.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddedServerEntities : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.EnsureSchema(
|
||||||
|
name: "Servers");
|
||||||
|
|
||||||
|
migrationBuilder.AlterDatabase()
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Nodes",
|
||||||
|
schema: "Servers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
Name = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Fqdn = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
ApiPort = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Token = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
SslEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Nodes", x => x.Id);
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "StarFolders",
|
||||||
|
schema: "Servers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
Name = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_StarFolders", x => x.Id);
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Networks",
|
||||||
|
schema: "Servers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
Name = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
NodeId = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Networks", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Networks_Nodes_NodeId",
|
||||||
|
column: x => x.NodeId,
|
||||||
|
principalSchema: "Servers",
|
||||||
|
principalTable: "Nodes",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Stars",
|
||||||
|
schema: "Servers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
Name = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Author = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
DonationUrl = table.Column<string>(type: "longtext", nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
UpdateUrl = table.Column<string>(type: "longtext", nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
StartupCommand = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
StopCommand = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
OnlineDetection = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
InstallShell = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
InstallDockerImage = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
InstallScript = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
RequiredAllocations = table.Column<int>(type: "int", nullable: false),
|
||||||
|
ParseConfiguration = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
DefaultDockerImageIndex = table.Column<int>(type: "int", nullable: false),
|
||||||
|
AllowDockerImageChanging = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||||
|
FolderId = table.Column<int>(type: "int", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Stars", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Stars_StarFolders_FolderId",
|
||||||
|
column: x => x.FolderId,
|
||||||
|
principalSchema: "Servers",
|
||||||
|
principalTable: "StarFolders",
|
||||||
|
principalColumn: "Id");
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Servers",
|
||||||
|
schema: "Servers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
Name = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Cpu = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Memory = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Disk = table.Column<int>(type: "int", nullable: false),
|
||||||
|
OverrideStartupCommand = table.Column<string>(type: "longtext", nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
OverrideDockerImage = table.Column<string>(type: "longtext", nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
VirtualDiskEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||||
|
StarId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
DockerImageIndex = table.Column<int>(type: "int", nullable: false),
|
||||||
|
NodeId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
NetworkId = table.Column<int>(type: "int", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Servers", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Servers_Networks_NetworkId",
|
||||||
|
column: x => x.NetworkId,
|
||||||
|
principalSchema: "Servers",
|
||||||
|
principalTable: "Networks",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Servers_Nodes_NodeId",
|
||||||
|
column: x => x.NodeId,
|
||||||
|
principalSchema: "Servers",
|
||||||
|
principalTable: "Nodes",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Servers_Stars_StarId",
|
||||||
|
column: x => x.StarId,
|
||||||
|
principalSchema: "Servers",
|
||||||
|
principalTable: "Stars",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "StarDockerImages",
|
||||||
|
schema: "Servers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
Identifier = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
DisplayName = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
AutoPulling = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||||
|
StarId = table.Column<int>(type: "int", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_StarDockerImages", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_StarDockerImages_Stars_StarId",
|
||||||
|
column: x => x.StarId,
|
||||||
|
principalSchema: "Servers",
|
||||||
|
principalTable: "Stars",
|
||||||
|
principalColumn: "Id");
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "StarVariables",
|
||||||
|
schema: "Servers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
Key = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
DefaultValue = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
DisplayName = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Description = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
AllowViewing = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||||
|
AllowEditing = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||||
|
Filter = table.Column<string>(type: "longtext", nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Type = table.Column<int>(type: "int", nullable: false),
|
||||||
|
StarId = table.Column<int>(type: "int", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_StarVariables", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_StarVariables_Stars_StarId",
|
||||||
|
column: x => x.StarId,
|
||||||
|
principalSchema: "Servers",
|
||||||
|
principalTable: "Stars",
|
||||||
|
principalColumn: "Id");
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Allocations",
|
||||||
|
schema: "Servers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
IpAddress = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Port = table.Column<int>(type: "int", nullable: false),
|
||||||
|
ServerId = table.Column<int>(type: "int", nullable: true),
|
||||||
|
NodeId = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Allocations", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Allocations_Nodes_NodeId",
|
||||||
|
column: x => x.NodeId,
|
||||||
|
principalSchema: "Servers",
|
||||||
|
principalTable: "Nodes",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Allocations_Servers_ServerId",
|
||||||
|
column: x => x.ServerId,
|
||||||
|
principalSchema: "Servers",
|
||||||
|
principalTable: "Servers",
|
||||||
|
principalColumn: "Id");
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Backups",
|
||||||
|
schema: "Servers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
Name = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
State = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Size = table.Column<long>(type: "bigint", nullable: false),
|
||||||
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||||
|
FinishedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||||
|
ServerId = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Backups", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Backups_Servers_ServerId",
|
||||||
|
column: x => x.ServerId,
|
||||||
|
principalSchema: "Servers",
|
||||||
|
principalTable: "Servers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "ServerVariables",
|
||||||
|
schema: "Servers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
Key = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Value = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
ServerId = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_ServerVariables", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_ServerVariables_Servers_ServerId",
|
||||||
|
column: x => x.ServerId,
|
||||||
|
principalSchema: "Servers",
|
||||||
|
principalTable: "Servers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Allocations_NodeId",
|
||||||
|
schema: "Servers",
|
||||||
|
table: "Allocations",
|
||||||
|
column: "NodeId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Allocations_ServerId",
|
||||||
|
schema: "Servers",
|
||||||
|
table: "Allocations",
|
||||||
|
column: "ServerId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Backups_ServerId",
|
||||||
|
schema: "Servers",
|
||||||
|
table: "Backups",
|
||||||
|
column: "ServerId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Networks_NodeId",
|
||||||
|
schema: "Servers",
|
||||||
|
table: "Networks",
|
||||||
|
column: "NodeId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Servers_NetworkId",
|
||||||
|
schema: "Servers",
|
||||||
|
table: "Servers",
|
||||||
|
column: "NetworkId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Servers_NodeId",
|
||||||
|
schema: "Servers",
|
||||||
|
table: "Servers",
|
||||||
|
column: "NodeId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Servers_StarId",
|
||||||
|
schema: "Servers",
|
||||||
|
table: "Servers",
|
||||||
|
column: "StarId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_ServerVariables_ServerId",
|
||||||
|
schema: "Servers",
|
||||||
|
table: "ServerVariables",
|
||||||
|
column: "ServerId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_StarDockerImages_StarId",
|
||||||
|
schema: "Servers",
|
||||||
|
table: "StarDockerImages",
|
||||||
|
column: "StarId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Stars_FolderId",
|
||||||
|
schema: "Servers",
|
||||||
|
table: "Stars",
|
||||||
|
column: "FolderId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_StarVariables_StarId",
|
||||||
|
schema: "Servers",
|
||||||
|
table: "StarVariables",
|
||||||
|
column: "StarId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Allocations",
|
||||||
|
schema: "Servers");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Backups",
|
||||||
|
schema: "Servers");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "ServerVariables",
|
||||||
|
schema: "Servers");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "StarDockerImages",
|
||||||
|
schema: "Servers");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "StarVariables",
|
||||||
|
schema: "Servers");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Servers",
|
||||||
|
schema: "Servers");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Networks",
|
||||||
|
schema: "Servers");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Stars",
|
||||||
|
schema: "Servers");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Nodes",
|
||||||
|
schema: "Servers");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "StarFolders",
|
||||||
|
schema: "Servers");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,516 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using MoonlightServers.ApiServer.Database;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace MoonlightServers.ApiServer.Database.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(ServersContext))]
|
||||||
|
partial class ServersContextModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasDefaultSchema("Servers")
|
||||||
|
.HasAnnotation("ProductVersion", "8.0.7")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||||
|
|
||||||
|
MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Allocation", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("IpAddress")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int>("NodeId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Port")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int?>("ServerId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NodeId");
|
||||||
|
|
||||||
|
b.HasIndex("ServerId");
|
||||||
|
|
||||||
|
b.ToTable("Allocations", "Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Backup", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.HasColumnType("datetime(6)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("FinishedAt")
|
||||||
|
.HasColumnType("datetime(6)");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int>("ServerId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<long>("Size")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<int>("State")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ServerId");
|
||||||
|
|
||||||
|
b.ToTable("Backups", "Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Network", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int>("NodeId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NodeId");
|
||||||
|
|
||||||
|
b.ToTable("Networks", "Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Node", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("ApiPort")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Fqdn")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<bool>("SslEnabled")
|
||||||
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
b.Property<string>("Token")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Nodes", "Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Server", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Cpu")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Disk")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("DockerImageIndex")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Memory")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int?>("NetworkId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("NodeId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("OverrideDockerImage")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("OverrideStartupCommand")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int>("StarId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<bool>("VirtualDiskEnabled")
|
||||||
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NetworkId");
|
||||||
|
|
||||||
|
b.HasIndex("NodeId");
|
||||||
|
|
||||||
|
b.HasIndex("StarId");
|
||||||
|
|
||||||
|
b.ToTable("Servers", "Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.ServerVariable", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Key")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int>("ServerId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ServerId");
|
||||||
|
|
||||||
|
b.ToTable("ServerVariables", "Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Star", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<bool>("AllowDockerImageChanging")
|
||||||
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
b.Property<string>("Author")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int>("DefaultDockerImageIndex")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("DonationUrl")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int?>("FolderId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("InstallDockerImage")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("InstallScript")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("InstallShell")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("OnlineDetection")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("ParseConfiguration")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int>("RequiredAllocations")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("StartupCommand")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("StopCommand")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("UpdateUrl")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("FolderId");
|
||||||
|
|
||||||
|
b.ToTable("Stars", "Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarDockerImage", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<bool>("AutoPulling")
|
||||||
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
b.Property<string>("DisplayName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("Identifier")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int?>("StarId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("StarId");
|
||||||
|
|
||||||
|
b.ToTable("StarDockerImages", "Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarFolder", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("StarFolders", "Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarVariable", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<bool>("AllowEditing")
|
||||||
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
b.Property<bool>("AllowViewing")
|
||||||
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
b.Property<string>("DefaultValue")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("DisplayName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("Filter")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("Key")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int?>("StarId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("StarId");
|
||||||
|
|
||||||
|
b.ToTable("StarVariables", "Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Allocation", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("MoonlightServers.ApiServer.Database.Entities.Node", "Node")
|
||||||
|
.WithMany("Allocations")
|
||||||
|
.HasForeignKey("NodeId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("MoonlightServers.ApiServer.Database.Entities.Server", "Server")
|
||||||
|
.WithMany("Allocations")
|
||||||
|
.HasForeignKey("ServerId");
|
||||||
|
|
||||||
|
b.Navigation("Node");
|
||||||
|
|
||||||
|
b.Navigation("Server");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Backup", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("MoonlightServers.ApiServer.Database.Entities.Server", "Server")
|
||||||
|
.WithMany("Backups")
|
||||||
|
.HasForeignKey("ServerId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Server");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Network", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("MoonlightServers.ApiServer.Database.Entities.Node", "Node")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("NodeId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Node");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Server", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("MoonlightServers.ApiServer.Database.Entities.Network", "Network")
|
||||||
|
.WithMany("Servers")
|
||||||
|
.HasForeignKey("NetworkId");
|
||||||
|
|
||||||
|
b.HasOne("MoonlightServers.ApiServer.Database.Entities.Node", "Node")
|
||||||
|
.WithMany("Servers")
|
||||||
|
.HasForeignKey("NodeId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("MoonlightServers.ApiServer.Database.Entities.Star", "Star")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("StarId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Network");
|
||||||
|
|
||||||
|
b.Navigation("Node");
|
||||||
|
|
||||||
|
b.Navigation("Star");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.ServerVariable", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("MoonlightServers.ApiServer.Database.Entities.Server", "Server")
|
||||||
|
.WithMany("Variables")
|
||||||
|
.HasForeignKey("ServerId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Server");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Star", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("MoonlightServers.ApiServer.Database.Entities.StarFolder", "Folder")
|
||||||
|
.WithMany("Stars")
|
||||||
|
.HasForeignKey("FolderId");
|
||||||
|
|
||||||
|
b.Navigation("Folder");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarDockerImage", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("MoonlightServers.ApiServer.Database.Entities.Star", null)
|
||||||
|
.WithMany("DockerImages")
|
||||||
|
.HasForeignKey("StarId");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarVariable", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("MoonlightServers.ApiServer.Database.Entities.Star", null)
|
||||||
|
.WithMany("Variables")
|
||||||
|
.HasForeignKey("StarId");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Network", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Node", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Allocations");
|
||||||
|
|
||||||
|
b.Navigation("Servers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Server", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Allocations");
|
||||||
|
|
||||||
|
b.Navigation("Backups");
|
||||||
|
|
||||||
|
b.Navigation("Variables");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Star", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("DockerImages");
|
||||||
|
|
||||||
|
b.Navigation("Variables");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarFolder", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Stars");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,21 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Moonlight.ApiServer.App.Helpers.Database;
|
using Moonlight.ApiServer.App.Helpers.Database;
|
||||||
|
using MoonlightServers.ApiServer.Database.Entities;
|
||||||
|
|
||||||
namespace MoonlightServers.ApiServer.Database;
|
namespace MoonlightServers.ApiServer.Database;
|
||||||
|
|
||||||
public class ServersContext : DatabaseContext
|
public class ServersContext : DatabaseContext
|
||||||
{
|
{
|
||||||
public override string Prefix => "Servers";
|
public override string Prefix => "Servers";
|
||||||
|
|
||||||
|
public DbSet<Allocation> Allocations { get; set; }
|
||||||
|
public DbSet<Backup> Backups { get; set; }
|
||||||
|
public DbSet<Network> Networks { get; set; }
|
||||||
|
public DbSet<Node> Nodes { get; set; }
|
||||||
|
public DbSet<Server> Servers { get; set; }
|
||||||
|
public DbSet<ServerVariable> ServerVariables { get; set; }
|
||||||
|
public DbSet<Star> Stars { get; set; }
|
||||||
|
public DbSet<StarDockerImage> StarDockerImages { get; set; }
|
||||||
|
public DbSet<StarFolder> StarFolders { get; set; }
|
||||||
|
public DbSet<StarVariable> StarVariables { get; set; }
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using MoonCore.Extended.Abstractions;
|
||||||
|
using MoonCore.Helpers;
|
||||||
|
using Moonlight.ApiServer.App.Attributes;
|
||||||
|
using Moonlight.ApiServer.App.Exceptions;
|
||||||
|
using Moonlight.ApiServer.App.Helpers;
|
||||||
|
using MoonlightServers.ApiServer.Database.Entities;
|
||||||
|
using MoonlightServers.Shared.Http.Requests.Admin.Nodes;
|
||||||
|
using MoonlightServers.Shared.Http.Responses.Admin.Nodes;
|
||||||
|
|
||||||
|
namespace MoonlightServers.ApiServer.Http.Controllers.Admin;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("admin/servers/nodes")]
|
||||||
|
public class NodesController : BaseCrudController<Node, DetailNodeResponse, CreateNodeRequest, DetailNodeResponse, UpdateNodeRequest, DetailNodeResponse>
|
||||||
|
{
|
||||||
|
private DatabaseRepository<Node> NodeRepository;
|
||||||
|
private DatabaseRepository<Allocation> AllocationRepository;
|
||||||
|
|
||||||
|
public NodesController(DatabaseRepository<Node> itemRepository, DatabaseRepository<Allocation> allocationRepository) : base(itemRepository)
|
||||||
|
{
|
||||||
|
PermissionPrefix = "admin.servers.nodes";
|
||||||
|
|
||||||
|
NodeRepository = itemRepository;
|
||||||
|
AllocationRepository = allocationRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[RequirePermission("admin.servers.nodes.create")]
|
||||||
|
public override async Task<ActionResult<DetailNodeResponse>> Create(CreateNodeRequest request)
|
||||||
|
{
|
||||||
|
ValidateFqdn(request.Fqdn, request.SslEnabled);
|
||||||
|
|
||||||
|
var node = Mapper.Map<Node>(request);
|
||||||
|
node.Token = Formatter.GenerateString(32);
|
||||||
|
|
||||||
|
var finalNode = NodeRepository.Add(node);
|
||||||
|
|
||||||
|
return Ok(Mapper.Map<DetailNodeResponse>(finalNode));
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPatch("{id}")]
|
||||||
|
[RequirePermission("admin.servers.nodes.update")]
|
||||||
|
public override async Task<ActionResult<DetailNodeResponse>> Update(int id, UpdateNodeRequest request)
|
||||||
|
{
|
||||||
|
ValidateFqdn(request.Fqdn, request.SslEnabled);
|
||||||
|
|
||||||
|
var item = LoadItemById(id);
|
||||||
|
|
||||||
|
item = Mapper.Map(item, request);
|
||||||
|
|
||||||
|
NodeRepository.Update(item);
|
||||||
|
|
||||||
|
return Ok(Mapper.Map<DetailNodeResponse>(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ValidateFqdn(string fqdn, bool ssl)
|
||||||
|
{
|
||||||
|
if (ssl)
|
||||||
|
{
|
||||||
|
// Is it a valid domain?
|
||||||
|
if (Regex.IsMatch(fqdn, "^(?!-)(?:[a-zA-Z\\d-]{0,62}[a-zA-Z\\d]\\.)+(?:[a-zA-Z]{2,})$"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
throw new ApiException("The fqdn needs to be a valid domain. If you want to use an ip address as the fqdn, disable ssl for this node", statusCode: 400);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Is it a valid domain?
|
||||||
|
if (Regex.IsMatch(fqdn, "^(?!-)(?:[a-zA-Z\\d-]{0,62}[a-zA-Z\\d]\\.)+(?:[a-zA-Z]{2,})$"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Is it a valid ip?
|
||||||
|
if (Regex.IsMatch(fqdn, "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
throw new ApiException("The fqdn needs to be either a domain or an ip", statusCode: 400);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allocations
|
||||||
|
|
||||||
|
}
|
||||||
@@ -37,10 +37,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Database\Entities\" />
|
<Folder Include="Database\Enums\" />
|
||||||
<Folder Include="Database\Migrations\" />
|
<Folder Include="Database\Migrations\" />
|
||||||
<Folder Include="Helpers\" />
|
<Folder Include="Helpers\" />
|
||||||
<Folder Include="Http\Controllers\" />
|
|
||||||
<Folder Include="Http\Hubs\" />
|
<Folder Include="Http\Hubs\" />
|
||||||
<Folder Include="Http\Middleware\" />
|
<Folder Include="Http\Middleware\" />
|
||||||
<Folder Include="Implementations\" />
|
<Folder Include="Implementations\" />
|
||||||
|
|||||||
@@ -36,7 +36,6 @@
|
|||||||
<Folder Include="Models\" />
|
<Folder Include="Models\" />
|
||||||
<Folder Include="Services\" />
|
<Folder Include="Services\" />
|
||||||
<Folder Include="UI\Components\" />
|
<Folder Include="UI\Components\" />
|
||||||
<Folder Include="UI\Views\" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
5
MoonlightServers.Client/UI/Views/Admin/Index.razor
Normal file
5
MoonlightServers.Client/UI/Views/Admin/Index.razor
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
@page "/admin/servers"
|
||||||
|
|
||||||
|
@attribute [RequirePermission("admin.servers.get")]
|
||||||
|
|
||||||
|
<NavTabs Index="0" TextSize="text-base" Names="@( ["Servers", "Nodes", "Stars", "Manager"])" Links="@( ["/admin/servers", "/admin/servers/nodes", "/admin/servers/stars", "admin/servers/manager"])"/>
|
||||||
87
MoonlightServers.Client/UI/Views/Admin/Nodes.razor
Normal file
87
MoonlightServers.Client/UI/Views/Admin/Nodes.razor
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
@page "/admin/servers/nodes"
|
||||||
|
|
||||||
|
@using Moonlight.Client.App.Models.Crud
|
||||||
|
@using Moonlight.Shared.Http.Resources
|
||||||
|
@using MoonlightServers.Shared.Http.Requests.Admin.Nodes
|
||||||
|
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes
|
||||||
|
|
||||||
|
@inject HttpApiClient HttpApiClient
|
||||||
|
|
||||||
|
@attribute [RequirePermission("admin.servers.nodes.get")]
|
||||||
|
|
||||||
|
<NavTabs Index="1" TextSize="text-base" Names="@( ["Servers", "Nodes", "Stars", "Manager"])" Links="@( ["/admin/servers", "/admin/servers/nodes", "/admin/servers/stars", "admin/servers/manager"])"/>
|
||||||
|
|
||||||
|
<div class="mt-5">
|
||||||
|
<SmartCrud TItem="DetailNodeResponse"
|
||||||
|
TCreateForm="CreateNodeRequest"
|
||||||
|
TUpdateForm="UpdateNodeRequest"
|
||||||
|
OnConfigure="OnConfigure">
|
||||||
|
<View>
|
||||||
|
<SmartColumn TItem="DetailNodeResponse" Field="@(x => x.Id)" Title="Id" />
|
||||||
|
<SmartColumn TItem="DetailNodeResponse" Field="@(x => x.Name)" Title="Name" />
|
||||||
|
<SmartColumn TItem="DetailNodeResponse" Field="@(x => x.Fqdn)" Title="FQDN" />
|
||||||
|
</View>
|
||||||
|
</SmartCrud>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code
|
||||||
|
{
|
||||||
|
private void OnConfigure(CrudOptions<DetailNodeResponse, CreateNodeRequest, UpdateNodeRequest> options)
|
||||||
|
{
|
||||||
|
options.Loader = async (page, pageSize) =>
|
||||||
|
await HttpApiClient.GetJson<PagedResponse<DetailNodeResponse>>($"admin/servers/nodes?page={page}&pageSize={pageSize}");
|
||||||
|
|
||||||
|
options.CreateFunction = async request => await HttpApiClient.Post("admin/servers/nodes", request);
|
||||||
|
options.UpdateFunction = async (request, item) => await HttpApiClient.Patch($"admin/servers/nodes/{item.Id}", request);
|
||||||
|
options.DeleteFunction = async item => await HttpApiClient.Delete($"admin/servers/nodes/{item.Id}");
|
||||||
|
|
||||||
|
options.ShowCreateAsModal = false;
|
||||||
|
options.ShowUpdateAsModal = false;
|
||||||
|
|
||||||
|
options.OnConfigureCreate = option =>
|
||||||
|
{
|
||||||
|
option
|
||||||
|
.DefaultPage
|
||||||
|
.DefaultSection
|
||||||
|
.AddProperty(x => x.Name);
|
||||||
|
|
||||||
|
option
|
||||||
|
.DefaultPage
|
||||||
|
.DefaultSection
|
||||||
|
.AddProperty(x => x.Fqdn);
|
||||||
|
|
||||||
|
option
|
||||||
|
.DefaultPage
|
||||||
|
.DefaultSection
|
||||||
|
.AddProperty(x => x.ApiPort);
|
||||||
|
|
||||||
|
option
|
||||||
|
.WithPage("Security")
|
||||||
|
.DefaultSection
|
||||||
|
.AddProperty(x => x.SslEnabled);
|
||||||
|
};
|
||||||
|
|
||||||
|
options.OnConfigureUpdate = (option, item) =>
|
||||||
|
{
|
||||||
|
option
|
||||||
|
.DefaultPage
|
||||||
|
.DefaultSection
|
||||||
|
.AddProperty(x => x.Name);
|
||||||
|
|
||||||
|
option
|
||||||
|
.DefaultPage
|
||||||
|
.DefaultSection
|
||||||
|
.AddProperty(x => x.Fqdn);
|
||||||
|
|
||||||
|
option
|
||||||
|
.DefaultPage
|
||||||
|
.DefaultSection
|
||||||
|
.AddProperty(x => x.ApiPort);
|
||||||
|
|
||||||
|
option
|
||||||
|
.DefaultPage
|
||||||
|
.DefaultSection
|
||||||
|
.AddProperty(x => x.SslEnabled);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
8
MoonlightServers.Shared/Enums/BackupState.cs
Normal file
8
MoonlightServers.Shared/Enums/BackupState.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace MoonlightServers.Shared.Enums;
|
||||||
|
|
||||||
|
public enum BackupState
|
||||||
|
{
|
||||||
|
Creating = 0,
|
||||||
|
Failed = 1,
|
||||||
|
Created = 2
|
||||||
|
}
|
||||||
9
MoonlightServers.Shared/Enums/StarVariableType.cs
Normal file
9
MoonlightServers.Shared/Enums/StarVariableType.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace MoonlightServers.Shared.Enums;
|
||||||
|
|
||||||
|
public enum StarVariableType
|
||||||
|
{
|
||||||
|
Text = 0,
|
||||||
|
Number = 1,
|
||||||
|
Toggle = 2,
|
||||||
|
Select = 3
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace MoonlightServers.Shared.Http.Requests.Admin.Nodes;
|
||||||
|
|
||||||
|
public class CreateNodeRequest
|
||||||
|
{
|
||||||
|
[Required(ErrorMessage = "You need to provide a name")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "You need to provide a fqdn")]
|
||||||
|
public string Fqdn { get; set; }
|
||||||
|
|
||||||
|
[Range(1, 65535, ErrorMessage = "You need to provide a valid port")]
|
||||||
|
public int ApiPort { get; set; } = 8080;
|
||||||
|
|
||||||
|
public bool SslEnabled { get; set; } = false;
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace MoonlightServers.Shared.Http.Requests.Admin.Nodes;
|
||||||
|
|
||||||
|
public class UpdateNodeRequest
|
||||||
|
{
|
||||||
|
[Required(ErrorMessage = "You need to provide a name")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "You need to provide a fqdn")]
|
||||||
|
public string Fqdn { get; set; }
|
||||||
|
|
||||||
|
[Range(1, 65535, ErrorMessage = "You need to provide a valid port")]
|
||||||
|
public int ApiPort { get; set; } = 8080;
|
||||||
|
|
||||||
|
public bool SslEnabled { get; set; } = false;
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
namespace MoonlightServers.Shared.Http.Responses.Admin.Nodes;
|
||||||
|
|
||||||
|
public class DetailNodeResponse
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Fqdn { get; set; }
|
||||||
|
public int ApiPort { get; set; }
|
||||||
|
public bool SslEnabled { get; set; }
|
||||||
|
}
|
||||||
@@ -7,8 +7,6 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Http\Requests\" />
|
|
||||||
<Folder Include="Http\Responses\" />
|
|
||||||
<Folder Include="Models\" />
|
<Folder Include="Models\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user