Added database entities, started with node crud
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user