Implemented template crud, db entities, import/export, ptero and pelican import

This commit is contained in:
2026-03-12 13:00:32 +00:00
parent 7c5dc657dc
commit e7b1e77d0a
68 changed files with 4269 additions and 24 deletions

View File

@@ -0,0 +1,139 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace MoonlightServers.Api.Infrastructure.Database.Migrations
{
/// <inheritdoc />
public partial class AddedTemplateEntities : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "TemplateDockerImages",
schema: "servers",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
DisplayName = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
ImageName = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
SkipPulling = table.Column<bool>(type: "boolean", nullable: false),
TemplateId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TemplateDockerImages", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Templates",
schema: "servers",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
Description = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
Author = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
Version = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
UpdateUrl = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
DonateUrl = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
AllowUserDockerImageChange = table.Column<bool>(type: "boolean", nullable: false),
DefaultDockerImageId = table.Column<int>(type: "integer", nullable: true),
FilesConfig = table.Column<string>(type: "jsonb", nullable: false),
InstallationConfig = table.Column<string>(type: "jsonb", nullable: false),
LifecycleConfig = table.Column<string>(type: "jsonb", nullable: false),
MiscellaneousConfig = table.Column<string>(type: "jsonb", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Templates", x => x.Id);
table.ForeignKey(
name: "FK_Templates_TemplateDockerImages_DefaultDockerImageId",
column: x => x.DefaultDockerImageId,
principalSchema: "servers",
principalTable: "TemplateDockerImages",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "TemplateVariablesVariables",
schema: "servers",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
DisplayName = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
Description = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
EnvName = table.Column<string>(type: "character varying(60)", maxLength: 60, nullable: false),
DefaultValue = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: false),
TemplateId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TemplateVariablesVariables", x => x.Id);
table.ForeignKey(
name: "FK_TemplateVariablesVariables_Templates_TemplateId",
column: x => x.TemplateId,
principalSchema: "servers",
principalTable: "Templates",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_TemplateDockerImages_TemplateId",
schema: "servers",
table: "TemplateDockerImages",
column: "TemplateId");
migrationBuilder.CreateIndex(
name: "IX_Templates_DefaultDockerImageId",
schema: "servers",
table: "Templates",
column: "DefaultDockerImageId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_TemplateVariablesVariables_TemplateId",
schema: "servers",
table: "TemplateVariablesVariables",
column: "TemplateId");
migrationBuilder.AddForeignKey(
name: "FK_TemplateDockerImages_Templates_TemplateId",
schema: "servers",
table: "TemplateDockerImages",
column: "TemplateId",
principalSchema: "servers",
principalTable: "Templates",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_TemplateDockerImages_Templates_TemplateId",
schema: "servers",
table: "TemplateDockerImages");
migrationBuilder.DropTable(
name: "TemplateVariablesVariables",
schema: "servers");
migrationBuilder.DropTable(
name: "Templates",
schema: "servers");
migrationBuilder.DropTable(
name: "TemplateDockerImages",
schema: "servers");
}
}
}