diff --git a/MoonlightServers.ApiServer/Database/Migrations/20241205154432_AddedBaseModels.Designer.cs b/MoonlightServers.ApiServer/Database/Migrations/20241205154432_AddedBaseModels.Designer.cs deleted file mode 100644 index 1eacfe9..0000000 --- a/MoonlightServers.ApiServer/Database/Migrations/20241205154432_AddedBaseModels.Designer.cs +++ /dev/null @@ -1,427 +0,0 @@ -// -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(ServersDataContext))] - [Migration("20241205154432_AddedBaseModels")] - partial class AddedBaseModels - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("Servers") - .HasAnnotation("ProductVersion", "8.0.11") - .HasAnnotation("Relational:MaxIdentifierLength", 64); - - MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Allocation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("IpAddress") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("NodeId") - .HasColumnType("int"); - - b.Property("Port") - .HasColumnType("int"); - - b.Property("ServerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("NodeId"); - - b.HasIndex("ServerId"); - - b.ToTable("Allocations", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Node", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("EnableDynamicFirewall") - .HasColumnType("tinyint(1)"); - - b.Property("EnableTransparentMode") - .HasColumnType("tinyint(1)"); - - b.Property("Fqdn") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FtpPort") - .HasColumnType("int"); - - b.Property("HttpPort") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Token") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Nodes", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Server", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("Bandwidth") - .HasColumnType("int"); - - b.Property("Cpu") - .HasColumnType("int"); - - b.Property("Disk") - .HasColumnType("int"); - - b.Property("DockerImageIndex") - .HasColumnType("int"); - - b.Property("Memory") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("NodeId") - .HasColumnType("int"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("StarId") - .HasColumnType("int"); - - b.Property("StartupOverride") - .HasColumnType("longtext"); - - b.Property("UseVirtualDisk") - .HasColumnType("tinyint(1)"); - - b.HasKey("Id"); - - b.HasIndex("NodeId"); - - b.HasIndex("StarId"); - - b.ToTable("Servers", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.ServerBackup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("Completed") - .HasColumnType("tinyint(1)"); - - b.Property("CompletedAt") - .HasColumnType("datetime(6)"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Size") - .HasColumnType("bigint"); - - b.Property("Successful") - .HasColumnType("tinyint(1)"); - - b.HasKey("Id"); - - b.ToTable("ServerBackups", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.ServerVariable", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ServerId") - .HasColumnType("int"); - - b.Property("Value") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ServerId"); - - b.ToTable("ServerVariables", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Star", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("AllowDockerImageChange") - .HasColumnType("tinyint(1)"); - - b.Property("Author") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("DonateUrl") - .HasColumnType("longtext"); - - b.Property("InstallDockerImage") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("InstallScript") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("InstallShell") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OnlineDetection") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ParseConfiguration") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("RequiredAllocations") - .HasColumnType("int"); - - b.Property("StartupCommand") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StopCommand") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UpdateUrl") - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Stars", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarDockerImage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("AutoPulling") - .HasColumnType("tinyint(1)"); - - b.Property("DisplayName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Identifier") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StarId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("StarId"); - - b.ToTable("StarDockerImages", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarVariable", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("AllowEditing") - .HasColumnType("tinyint(1)"); - - b.Property("AllowViewing") - .HasColumnType("tinyint(1)"); - - b.Property("DefaultValue") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Filter") - .HasColumnType("longtext"); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StarId") - .HasColumnType("int"); - - b.Property("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.Server", b => - { - 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("Node"); - - b.Navigation("Star"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.ServerVariable", b => - { - b.HasOne("MoonlightServers.ApiServer.Database.Entities.Server", "Server") - .WithMany() - .HasForeignKey("ServerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Server"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarDockerImage", b => - { - b.HasOne("MoonlightServers.ApiServer.Database.Entities.Star", "Star") - .WithMany("DockerImages") - .HasForeignKey("StarId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Star"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarVariable", b => - { - b.HasOne("MoonlightServers.ApiServer.Database.Entities.Star", "Star") - .WithMany("Variables") - .HasForeignKey("StarId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Star"); - }); - - 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"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Star", b => - { - b.Navigation("DockerImages"); - - b.Navigation("Variables"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MoonlightServers.ApiServer/Database/Migrations/20241205154432_AddedBaseModels.cs b/MoonlightServers.ApiServer/Database/Migrations/20241205154432_AddedBaseModels.cs deleted file mode 100644 index af09afa..0000000 --- a/MoonlightServers.ApiServer/Database/Migrations/20241205154432_AddedBaseModels.cs +++ /dev/null @@ -1,342 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MoonlightServers.ApiServer.Database.Migrations -{ - /// - public partial class AddedBaseModels : Migration - { - /// - 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(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Fqdn = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Token = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - HttpPort = table.Column(type: "int", nullable: false), - FtpPort = table.Column(type: "int", nullable: false), - EnableTransparentMode = table.Column(type: "tinyint(1)", nullable: false), - EnableDynamicFirewall = table.Column(type: "tinyint(1)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Nodes", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "ServerBackups", - schema: "Servers", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - CreatedAt = table.Column(type: "datetime(6)", nullable: false), - CompletedAt = table.Column(type: "datetime(6)", nullable: false), - Size = table.Column(type: "bigint", nullable: false), - Successful = table.Column(type: "tinyint(1)", nullable: false), - Completed = table.Column(type: "tinyint(1)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ServerBackups", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "Stars", - schema: "Servers", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Author = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - UpdateUrl = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - DonateUrl = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - StartupCommand = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - StopCommand = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - OnlineDetection = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - InstallShell = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - InstallDockerImage = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - InstallScript = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - RequiredAllocations = table.Column(type: "int", nullable: false), - AllowDockerImageChange = table.Column(type: "tinyint(1)", nullable: false), - ParseConfiguration = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_Stars", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "Servers", - schema: "Servers", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - StarId = table.Column(type: "int", nullable: false), - NodeId = table.Column(type: "int", nullable: false), - Name = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - OwnerId = table.Column(type: "int", nullable: false), - StartupOverride = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - DockerImageIndex = table.Column(type: "int", nullable: false), - Cpu = table.Column(type: "int", nullable: false), - Memory = table.Column(type: "int", nullable: false), - Disk = table.Column(type: "int", nullable: false), - UseVirtualDisk = table.Column(type: "tinyint(1)", nullable: false), - Bandwidth = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Servers", x => x.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(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - StarId = table.Column(type: "int", nullable: false), - DisplayName = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Identifier = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - AutoPulling = table.Column(type: "tinyint(1)", nullable: false) - }, - 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", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "StarVariables", - schema: "Servers", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - StarId = table.Column(type: "int", nullable: false), - Name = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Description = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Key = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - DefaultValue = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - AllowViewing = table.Column(type: "tinyint(1)", nullable: false), - AllowEditing = table.Column(type: "tinyint(1)", nullable: false), - Type = table.Column(type: "int", nullable: false), - Filter = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - 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", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "Allocations", - schema: "Servers", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - NodeId = table.Column(type: "int", nullable: false), - ServerId = table.Column(type: "int", nullable: true), - IpAddress = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Port = table.Column(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: "ServerVariables", - schema: "Servers", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ServerId = table.Column(type: "int", nullable: false), - Key = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Value = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - 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_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_StarVariables_StarId", - schema: "Servers", - table: "StarVariables", - column: "StarId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Allocations", - schema: "Servers"); - - migrationBuilder.DropTable( - name: "ServerBackups", - 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: "Nodes", - schema: "Servers"); - - migrationBuilder.DropTable( - name: "Stars", - schema: "Servers"); - } - } -} diff --git a/MoonlightServers.ApiServer/Database/Migrations/20241206083153_AddedVersionTagForStar.Designer.cs b/MoonlightServers.ApiServer/Database/Migrations/20241206083153_AddedVersionTagForStar.Designer.cs deleted file mode 100644 index 1834021..0000000 --- a/MoonlightServers.ApiServer/Database/Migrations/20241206083153_AddedVersionTagForStar.Designer.cs +++ /dev/null @@ -1,431 +0,0 @@ -// -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(ServersDataContext))] - [Migration("20241206083153_AddedVersionTagForStar")] - partial class AddedVersionTagForStar - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("Servers") - .HasAnnotation("ProductVersion", "8.0.11") - .HasAnnotation("Relational:MaxIdentifierLength", 64); - - MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Allocation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("IpAddress") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("NodeId") - .HasColumnType("int"); - - b.Property("Port") - .HasColumnType("int"); - - b.Property("ServerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("NodeId"); - - b.HasIndex("ServerId"); - - b.ToTable("Allocations", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Node", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("EnableDynamicFirewall") - .HasColumnType("tinyint(1)"); - - b.Property("EnableTransparentMode") - .HasColumnType("tinyint(1)"); - - b.Property("Fqdn") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FtpPort") - .HasColumnType("int"); - - b.Property("HttpPort") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Token") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Nodes", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Server", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("Bandwidth") - .HasColumnType("int"); - - b.Property("Cpu") - .HasColumnType("int"); - - b.Property("Disk") - .HasColumnType("int"); - - b.Property("DockerImageIndex") - .HasColumnType("int"); - - b.Property("Memory") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("NodeId") - .HasColumnType("int"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("StarId") - .HasColumnType("int"); - - b.Property("StartupOverride") - .HasColumnType("longtext"); - - b.Property("UseVirtualDisk") - .HasColumnType("tinyint(1)"); - - b.HasKey("Id"); - - b.HasIndex("NodeId"); - - b.HasIndex("StarId"); - - b.ToTable("Servers", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.ServerBackup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("Completed") - .HasColumnType("tinyint(1)"); - - b.Property("CompletedAt") - .HasColumnType("datetime(6)"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Size") - .HasColumnType("bigint"); - - b.Property("Successful") - .HasColumnType("tinyint(1)"); - - b.HasKey("Id"); - - b.ToTable("ServerBackups", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.ServerVariable", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ServerId") - .HasColumnType("int"); - - b.Property("Value") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ServerId"); - - b.ToTable("ServerVariables", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Star", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("AllowDockerImageChange") - .HasColumnType("tinyint(1)"); - - b.Property("Author") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("DonateUrl") - .HasColumnType("longtext"); - - b.Property("InstallDockerImage") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("InstallScript") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("InstallShell") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OnlineDetection") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ParseConfiguration") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("RequiredAllocations") - .HasColumnType("int"); - - b.Property("StartupCommand") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StopCommand") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UpdateUrl") - .HasColumnType("longtext"); - - b.Property("Version") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Stars", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarDockerImage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("AutoPulling") - .HasColumnType("tinyint(1)"); - - b.Property("DisplayName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Identifier") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StarId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("StarId"); - - b.ToTable("StarDockerImages", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarVariable", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("AllowEditing") - .HasColumnType("tinyint(1)"); - - b.Property("AllowViewing") - .HasColumnType("tinyint(1)"); - - b.Property("DefaultValue") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Filter") - .HasColumnType("longtext"); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StarId") - .HasColumnType("int"); - - b.Property("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.Server", b => - { - 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("Node"); - - b.Navigation("Star"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.ServerVariable", b => - { - b.HasOne("MoonlightServers.ApiServer.Database.Entities.Server", "Server") - .WithMany() - .HasForeignKey("ServerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Server"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarDockerImage", b => - { - b.HasOne("MoonlightServers.ApiServer.Database.Entities.Star", "Star") - .WithMany("DockerImages") - .HasForeignKey("StarId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Star"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarVariable", b => - { - b.HasOne("MoonlightServers.ApiServer.Database.Entities.Star", "Star") - .WithMany("Variables") - .HasForeignKey("StarId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Star"); - }); - - 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"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Star", b => - { - b.Navigation("DockerImages"); - - b.Navigation("Variables"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MoonlightServers.ApiServer/Database/Migrations/20241206083153_AddedVersionTagForStar.cs b/MoonlightServers.ApiServer/Database/Migrations/20241206083153_AddedVersionTagForStar.cs deleted file mode 100644 index 60778f5..0000000 --- a/MoonlightServers.ApiServer/Database/Migrations/20241206083153_AddedVersionTagForStar.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MoonlightServers.ApiServer.Database.Migrations -{ - /// - public partial class AddedVersionTagForStar : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Version", - schema: "Servers", - table: "Stars", - type: "longtext", - nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Version", - schema: "Servers", - table: "Stars"); - } - } -} diff --git a/MoonlightServers.ApiServer/Database/Migrations/20241211075318_AddedDefaultDockerImageField.Designer.cs b/MoonlightServers.ApiServer/Database/Migrations/20241211075318_AddedDefaultDockerImageField.Designer.cs deleted file mode 100644 index 131800f..0000000 --- a/MoonlightServers.ApiServer/Database/Migrations/20241211075318_AddedDefaultDockerImageField.Designer.cs +++ /dev/null @@ -1,434 +0,0 @@ -// -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(ServersDataContext))] - [Migration("20241211075318_AddedDefaultDockerImageField")] - partial class AddedDefaultDockerImageField - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("Servers") - .HasAnnotation("ProductVersion", "8.0.11") - .HasAnnotation("Relational:MaxIdentifierLength", 64); - - MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Allocation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("IpAddress") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("NodeId") - .HasColumnType("int"); - - b.Property("Port") - .HasColumnType("int"); - - b.Property("ServerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("NodeId"); - - b.HasIndex("ServerId"); - - b.ToTable("Allocations", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Node", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("EnableDynamicFirewall") - .HasColumnType("tinyint(1)"); - - b.Property("EnableTransparentMode") - .HasColumnType("tinyint(1)"); - - b.Property("Fqdn") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FtpPort") - .HasColumnType("int"); - - b.Property("HttpPort") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Token") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Nodes", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Server", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("Bandwidth") - .HasColumnType("int"); - - b.Property("Cpu") - .HasColumnType("int"); - - b.Property("Disk") - .HasColumnType("int"); - - b.Property("DockerImageIndex") - .HasColumnType("int"); - - b.Property("Memory") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("NodeId") - .HasColumnType("int"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("StarId") - .HasColumnType("int"); - - b.Property("StartupOverride") - .HasColumnType("longtext"); - - b.Property("UseVirtualDisk") - .HasColumnType("tinyint(1)"); - - b.HasKey("Id"); - - b.HasIndex("NodeId"); - - b.HasIndex("StarId"); - - b.ToTable("Servers", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.ServerBackup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("Completed") - .HasColumnType("tinyint(1)"); - - b.Property("CompletedAt") - .HasColumnType("datetime(6)"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Size") - .HasColumnType("bigint"); - - b.Property("Successful") - .HasColumnType("tinyint(1)"); - - b.HasKey("Id"); - - b.ToTable("ServerBackups", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.ServerVariable", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ServerId") - .HasColumnType("int"); - - b.Property("Value") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ServerId"); - - b.ToTable("ServerVariables", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Star", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("AllowDockerImageChange") - .HasColumnType("tinyint(1)"); - - b.Property("Author") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("DefaultDockerImage") - .HasColumnType("int"); - - b.Property("DonateUrl") - .HasColumnType("longtext"); - - b.Property("InstallDockerImage") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("InstallScript") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("InstallShell") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OnlineDetection") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ParseConfiguration") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("RequiredAllocations") - .HasColumnType("int"); - - b.Property("StartupCommand") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StopCommand") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UpdateUrl") - .HasColumnType("longtext"); - - b.Property("Version") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Stars", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarDockerImage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("AutoPulling") - .HasColumnType("tinyint(1)"); - - b.Property("DisplayName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Identifier") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StarId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("StarId"); - - b.ToTable("StarDockerImages", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarVariable", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("AllowEditing") - .HasColumnType("tinyint(1)"); - - b.Property("AllowViewing") - .HasColumnType("tinyint(1)"); - - b.Property("DefaultValue") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Filter") - .HasColumnType("longtext"); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StarId") - .HasColumnType("int"); - - b.Property("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.Server", b => - { - 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("Node"); - - b.Navigation("Star"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.ServerVariable", b => - { - b.HasOne("MoonlightServers.ApiServer.Database.Entities.Server", "Server") - .WithMany() - .HasForeignKey("ServerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Server"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarDockerImage", b => - { - b.HasOne("MoonlightServers.ApiServer.Database.Entities.Star", "Star") - .WithMany("DockerImages") - .HasForeignKey("StarId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Star"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarVariable", b => - { - b.HasOne("MoonlightServers.ApiServer.Database.Entities.Star", "Star") - .WithMany("Variables") - .HasForeignKey("StarId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Star"); - }); - - 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"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Star", b => - { - b.Navigation("DockerImages"); - - b.Navigation("Variables"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MoonlightServers.ApiServer/Database/Migrations/20241211075318_AddedDefaultDockerImageField.cs b/MoonlightServers.ApiServer/Database/Migrations/20241211075318_AddedDefaultDockerImageField.cs deleted file mode 100644 index 5b5cf05..0000000 --- a/MoonlightServers.ApiServer/Database/Migrations/20241211075318_AddedDefaultDockerImageField.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MoonlightServers.ApiServer.Database.Migrations -{ - /// - public partial class AddedDefaultDockerImageField : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "DefaultDockerImage", - schema: "Servers", - table: "Stars", - type: "int", - nullable: false, - defaultValue: 0); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "DefaultDockerImage", - schema: "Servers", - table: "Stars"); - } - } -} diff --git a/MoonlightServers.ApiServer/Database/Migrations/20241213181416_AddedNodeSslField.Designer.cs b/MoonlightServers.ApiServer/Database/Migrations/20241213181416_AddedNodeSslField.Designer.cs deleted file mode 100644 index 8d0f772..0000000 --- a/MoonlightServers.ApiServer/Database/Migrations/20241213181416_AddedNodeSslField.Designer.cs +++ /dev/null @@ -1,437 +0,0 @@ -// -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(ServersDataContext))] - [Migration("20241213181416_AddedNodeSslField")] - partial class AddedNodeSslField - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("Servers") - .HasAnnotation("ProductVersion", "8.0.11") - .HasAnnotation("Relational:MaxIdentifierLength", 64); - - MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Allocation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("IpAddress") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("NodeId") - .HasColumnType("int"); - - b.Property("Port") - .HasColumnType("int"); - - b.Property("ServerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("NodeId"); - - b.HasIndex("ServerId"); - - b.ToTable("Allocations", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Node", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("EnableDynamicFirewall") - .HasColumnType("tinyint(1)"); - - b.Property("EnableTransparentMode") - .HasColumnType("tinyint(1)"); - - b.Property("Fqdn") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FtpPort") - .HasColumnType("int"); - - b.Property("HttpPort") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Token") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UseSsl") - .HasColumnType("tinyint(1)"); - - b.HasKey("Id"); - - b.ToTable("Nodes", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Server", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("Bandwidth") - .HasColumnType("int"); - - b.Property("Cpu") - .HasColumnType("int"); - - b.Property("Disk") - .HasColumnType("int"); - - b.Property("DockerImageIndex") - .HasColumnType("int"); - - b.Property("Memory") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("NodeId") - .HasColumnType("int"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("StarId") - .HasColumnType("int"); - - b.Property("StartupOverride") - .HasColumnType("longtext"); - - b.Property("UseVirtualDisk") - .HasColumnType("tinyint(1)"); - - b.HasKey("Id"); - - b.HasIndex("NodeId"); - - b.HasIndex("StarId"); - - b.ToTable("Servers", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.ServerBackup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("Completed") - .HasColumnType("tinyint(1)"); - - b.Property("CompletedAt") - .HasColumnType("datetime(6)"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Size") - .HasColumnType("bigint"); - - b.Property("Successful") - .HasColumnType("tinyint(1)"); - - b.HasKey("Id"); - - b.ToTable("ServerBackups", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.ServerVariable", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ServerId") - .HasColumnType("int"); - - b.Property("Value") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ServerId"); - - b.ToTable("ServerVariables", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Star", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("AllowDockerImageChange") - .HasColumnType("tinyint(1)"); - - b.Property("Author") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("DefaultDockerImage") - .HasColumnType("int"); - - b.Property("DonateUrl") - .HasColumnType("longtext"); - - b.Property("InstallDockerImage") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("InstallScript") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("InstallShell") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OnlineDetection") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ParseConfiguration") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("RequiredAllocations") - .HasColumnType("int"); - - b.Property("StartupCommand") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StopCommand") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UpdateUrl") - .HasColumnType("longtext"); - - b.Property("Version") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Stars", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarDockerImage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("AutoPulling") - .HasColumnType("tinyint(1)"); - - b.Property("DisplayName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Identifier") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StarId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("StarId"); - - b.ToTable("StarDockerImages", "Servers"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarVariable", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - - b.Property("AllowEditing") - .HasColumnType("tinyint(1)"); - - b.Property("AllowViewing") - .HasColumnType("tinyint(1)"); - - b.Property("DefaultValue") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Filter") - .HasColumnType("longtext"); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StarId") - .HasColumnType("int"); - - b.Property("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.Server", b => - { - 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("Node"); - - b.Navigation("Star"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.ServerVariable", b => - { - b.HasOne("MoonlightServers.ApiServer.Database.Entities.Server", "Server") - .WithMany() - .HasForeignKey("ServerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Server"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarDockerImage", b => - { - b.HasOne("MoonlightServers.ApiServer.Database.Entities.Star", "Star") - .WithMany("DockerImages") - .HasForeignKey("StarId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Star"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarVariable", b => - { - b.HasOne("MoonlightServers.ApiServer.Database.Entities.Star", "Star") - .WithMany("Variables") - .HasForeignKey("StarId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Star"); - }); - - 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"); - }); - - modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Star", b => - { - b.Navigation("DockerImages"); - - b.Navigation("Variables"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MoonlightServers.ApiServer/Database/Migrations/20241213181416_AddedNodeSslField.cs b/MoonlightServers.ApiServer/Database/Migrations/20241213181416_AddedNodeSslField.cs deleted file mode 100644 index db77984..0000000 --- a/MoonlightServers.ApiServer/Database/Migrations/20241213181416_AddedNodeSslField.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MoonlightServers.ApiServer.Database.Migrations -{ - /// - public partial class AddedNodeSslField : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "UseSsl", - schema: "Servers", - table: "Nodes", - type: "tinyint(1)", - nullable: false, - defaultValue: false); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "UseSsl", - schema: "Servers", - table: "Nodes"); - } - } -} diff --git a/MoonlightServers.ApiServer/Database/Migrations/20241215151257_AddedServerRelations.cs b/MoonlightServers.ApiServer/Database/Migrations/20241215151257_AddedServerRelations.cs deleted file mode 100644 index c13aef3..0000000 --- a/MoonlightServers.ApiServer/Database/Migrations/20241215151257_AddedServerRelations.cs +++ /dev/null @@ -1,55 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MoonlightServers.ApiServer.Database.Migrations -{ - /// - public partial class AddedServerRelations : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "ServerId", - schema: "Servers", - table: "ServerBackups", - type: "int", - nullable: true); - - migrationBuilder.CreateIndex( - name: "IX_ServerBackups_ServerId", - schema: "Servers", - table: "ServerBackups", - column: "ServerId"); - - migrationBuilder.AddForeignKey( - name: "FK_ServerBackups_Servers_ServerId", - schema: "Servers", - table: "ServerBackups", - column: "ServerId", - principalSchema: "Servers", - principalTable: "Servers", - principalColumn: "Id"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_ServerBackups_Servers_ServerId", - schema: "Servers", - table: "ServerBackups"); - - migrationBuilder.DropIndex( - name: "IX_ServerBackups_ServerId", - schema: "Servers", - table: "ServerBackups"); - - migrationBuilder.DropColumn( - name: "ServerId", - schema: "Servers", - table: "ServerBackups"); - } - } -} diff --git a/MoonlightServers.ApiServer/Database/Migrations/20241215151257_AddedServerRelations.Designer.cs b/MoonlightServers.ApiServer/Database/Migrations/20250226210232_RecreatedMigrationsForPostgresql.Designer.cs similarity index 69% rename from MoonlightServers.ApiServer/Database/Migrations/20241215151257_AddedServerRelations.Designer.cs rename to MoonlightServers.ApiServer/Database/Migrations/20250226210232_RecreatedMigrationsForPostgresql.Designer.cs index 0d8d09a..3ea509c 100644 --- a/MoonlightServers.ApiServer/Database/Migrations/20241215151257_AddedServerRelations.Designer.cs +++ b/MoonlightServers.ApiServer/Database/Migrations/20250226210232_RecreatedMigrationsForPostgresql.Designer.cs @@ -2,50 +2,49 @@ 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; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace MoonlightServers.ApiServer.Database.Migrations { [DbContext(typeof(ServersDataContext))] - [Migration("20241215151257_AddedServerRelations")] - partial class AddedServerRelations + [Migration("20250226210232_RecreatedMigrationsForPostgresql")] + partial class RecreatedMigrationsForPostgresql { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasDefaultSchema("Servers") .HasAnnotation("ProductVersion", "8.0.11") - .HasAnnotation("Relational:MaxIdentifierLength", 64); + .HasAnnotation("Relational:MaxIdentifierLength", 63); - MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Allocation", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("IpAddress") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("NodeId") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("Port") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("ServerId") - .HasColumnType("int"); + .HasColumnType("integer"); b.HasKey("Id"); @@ -53,90 +52,90 @@ namespace MoonlightServers.ApiServer.Database.Migrations b.HasIndex("ServerId"); - b.ToTable("Allocations", "Servers"); + b.ToTable("Servers_Allocations", (string)null); }); modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Node", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("EnableDynamicFirewall") - .HasColumnType("tinyint(1)"); + .HasColumnType("boolean"); b.Property("EnableTransparentMode") - .HasColumnType("tinyint(1)"); + .HasColumnType("boolean"); b.Property("Fqdn") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("FtpPort") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("HttpPort") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("Name") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Token") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("UseSsl") - .HasColumnType("tinyint(1)"); + .HasColumnType("boolean"); b.HasKey("Id"); - b.ToTable("Nodes", "Servers"); + b.ToTable("Servers_Nodes", (string)null); }); modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Server", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Bandwidth") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("Cpu") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("Disk") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("DockerImageIndex") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("Memory") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("Name") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("NodeId") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("OwnerId") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("StarId") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("StartupOverride") - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("UseVirtualDisk") - .HasColumnType("tinyint(1)"); + .HasColumnType("boolean"); b.HasKey("Id"); @@ -144,209 +143,209 @@ namespace MoonlightServers.ApiServer.Database.Migrations b.HasIndex("StarId"); - b.ToTable("Servers", "Servers"); + b.ToTable("Servers_Servers", (string)null); }); modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.ServerBackup", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Completed") - .HasColumnType("tinyint(1)"); + .HasColumnType("boolean"); b.Property("CompletedAt") - .HasColumnType("datetime(6)"); + .HasColumnType("timestamp with time zone"); b.Property("CreatedAt") - .HasColumnType("datetime(6)"); + .HasColumnType("timestamp with time zone"); b.Property("ServerId") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("Size") .HasColumnType("bigint"); b.Property("Successful") - .HasColumnType("tinyint(1)"); + .HasColumnType("boolean"); b.HasKey("Id"); b.HasIndex("ServerId"); - b.ToTable("ServerBackups", "Servers"); + b.ToTable("Servers_ServerBackups", (string)null); }); modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.ServerVariable", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Key") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("ServerId") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("Value") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.HasKey("Id"); b.HasIndex("ServerId"); - b.ToTable("ServerVariables", "Servers"); + b.ToTable("Servers_ServerVariables", (string)null); }); modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Star", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("AllowDockerImageChange") - .HasColumnType("tinyint(1)"); + .HasColumnType("boolean"); b.Property("Author") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("DefaultDockerImage") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("DonateUrl") - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("InstallDockerImage") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("InstallScript") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("InstallShell") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Name") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("OnlineDetection") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("ParseConfiguration") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("RequiredAllocations") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("StartupCommand") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("StopCommand") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("UpdateUrl") - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Version") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.HasKey("Id"); - b.ToTable("Stars", "Servers"); + b.ToTable("Servers_Stars", (string)null); }); modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarDockerImage", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("AutoPulling") - .HasColumnType("tinyint(1)"); + .HasColumnType("boolean"); b.Property("DisplayName") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Identifier") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("StarId") - .HasColumnType("int"); + .HasColumnType("integer"); b.HasKey("Id"); b.HasIndex("StarId"); - b.ToTable("StarDockerImages", "Servers"); + b.ToTable("Servers_StarDockerImages", (string)null); }); modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarVariable", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("AllowEditing") - .HasColumnType("tinyint(1)"); + .HasColumnType("boolean"); b.Property("AllowViewing") - .HasColumnType("tinyint(1)"); + .HasColumnType("boolean"); b.Property("DefaultValue") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Description") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Filter") - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Key") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Name") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("StarId") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("Type") - .HasColumnType("int"); + .HasColumnType("integer"); b.HasKey("Id"); b.HasIndex("StarId"); - b.ToTable("StarVariables", "Servers"); + b.ToTable("Servers_StarVariables", (string)null); }); modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Allocation", b => diff --git a/MoonlightServers.ApiServer/Database/Migrations/20250226210232_RecreatedMigrationsForPostgresql.cs b/MoonlightServers.ApiServer/Database/Migrations/20250226210232_RecreatedMigrationsForPostgresql.cs new file mode 100644 index 0000000..cf9b503 --- /dev/null +++ b/MoonlightServers.ApiServer/Database/Migrations/20250226210232_RecreatedMigrationsForPostgresql.cs @@ -0,0 +1,286 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MoonlightServers.ApiServer.Database.Migrations +{ + /// + public partial class RecreatedMigrationsForPostgresql : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Servers_Nodes", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + Fqdn = table.Column(type: "text", nullable: false), + Token = table.Column(type: "text", nullable: false), + HttpPort = table.Column(type: "integer", nullable: false), + FtpPort = table.Column(type: "integer", nullable: false), + UseSsl = table.Column(type: "boolean", nullable: false), + EnableTransparentMode = table.Column(type: "boolean", nullable: false), + EnableDynamicFirewall = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Servers_Nodes", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Servers_Stars", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + Version = table.Column(type: "text", nullable: false), + Author = table.Column(type: "text", nullable: false), + UpdateUrl = table.Column(type: "text", nullable: true), + DonateUrl = table.Column(type: "text", nullable: true), + StartupCommand = table.Column(type: "text", nullable: false), + StopCommand = table.Column(type: "text", nullable: false), + OnlineDetection = table.Column(type: "text", nullable: false), + InstallShell = table.Column(type: "text", nullable: false), + InstallDockerImage = table.Column(type: "text", nullable: false), + InstallScript = table.Column(type: "text", nullable: false), + RequiredAllocations = table.Column(type: "integer", nullable: false), + AllowDockerImageChange = table.Column(type: "boolean", nullable: false), + DefaultDockerImage = table.Column(type: "integer", nullable: false), + ParseConfiguration = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Servers_Stars", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Servers_Servers", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + StarId = table.Column(type: "integer", nullable: false), + NodeId = table.Column(type: "integer", nullable: false), + Name = table.Column(type: "text", nullable: false), + OwnerId = table.Column(type: "integer", nullable: false), + StartupOverride = table.Column(type: "text", nullable: true), + DockerImageIndex = table.Column(type: "integer", nullable: false), + Cpu = table.Column(type: "integer", nullable: false), + Memory = table.Column(type: "integer", nullable: false), + Disk = table.Column(type: "integer", nullable: false), + UseVirtualDisk = table.Column(type: "boolean", nullable: false), + Bandwidth = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Servers_Servers", x => x.Id); + table.ForeignKey( + name: "FK_Servers_Servers_Servers_Nodes_NodeId", + column: x => x.NodeId, + principalTable: "Servers_Nodes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Servers_Servers_Servers_Stars_StarId", + column: x => x.StarId, + principalTable: "Servers_Stars", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Servers_StarDockerImages", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + StarId = table.Column(type: "integer", nullable: false), + DisplayName = table.Column(type: "text", nullable: false), + Identifier = table.Column(type: "text", nullable: false), + AutoPulling = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Servers_StarDockerImages", x => x.Id); + table.ForeignKey( + name: "FK_Servers_StarDockerImages_Servers_Stars_StarId", + column: x => x.StarId, + principalTable: "Servers_Stars", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Servers_StarVariables", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + StarId = table.Column(type: "integer", nullable: false), + Name = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: false), + Key = table.Column(type: "text", nullable: false), + DefaultValue = table.Column(type: "text", nullable: false), + AllowViewing = table.Column(type: "boolean", nullable: false), + AllowEditing = table.Column(type: "boolean", nullable: false), + Type = table.Column(type: "integer", nullable: false), + Filter = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Servers_StarVariables", x => x.Id); + table.ForeignKey( + name: "FK_Servers_StarVariables_Servers_Stars_StarId", + column: x => x.StarId, + principalTable: "Servers_Stars", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Servers_Allocations", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + NodeId = table.Column(type: "integer", nullable: false), + ServerId = table.Column(type: "integer", nullable: true), + IpAddress = table.Column(type: "text", nullable: false), + Port = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Servers_Allocations", x => x.Id); + table.ForeignKey( + name: "FK_Servers_Allocations_Servers_Nodes_NodeId", + column: x => x.NodeId, + principalTable: "Servers_Nodes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Servers_Allocations_Servers_Servers_ServerId", + column: x => x.ServerId, + principalTable: "Servers_Servers", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "Servers_ServerBackups", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + CompletedAt = table.Column(type: "timestamp with time zone", nullable: false), + Size = table.Column(type: "bigint", nullable: false), + Successful = table.Column(type: "boolean", nullable: false), + Completed = table.Column(type: "boolean", nullable: false), + ServerId = table.Column(type: "integer", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Servers_ServerBackups", x => x.Id); + table.ForeignKey( + name: "FK_Servers_ServerBackups_Servers_Servers_ServerId", + column: x => x.ServerId, + principalTable: "Servers_Servers", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "Servers_ServerVariables", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ServerId = table.Column(type: "integer", nullable: false), + Key = table.Column(type: "text", nullable: false), + Value = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Servers_ServerVariables", x => x.Id); + table.ForeignKey( + name: "FK_Servers_ServerVariables_Servers_Servers_ServerId", + column: x => x.ServerId, + principalTable: "Servers_Servers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Servers_Allocations_NodeId", + table: "Servers_Allocations", + column: "NodeId"); + + migrationBuilder.CreateIndex( + name: "IX_Servers_Allocations_ServerId", + table: "Servers_Allocations", + column: "ServerId"); + + migrationBuilder.CreateIndex( + name: "IX_Servers_ServerBackups_ServerId", + table: "Servers_ServerBackups", + column: "ServerId"); + + migrationBuilder.CreateIndex( + name: "IX_Servers_Servers_NodeId", + table: "Servers_Servers", + column: "NodeId"); + + migrationBuilder.CreateIndex( + name: "IX_Servers_Servers_StarId", + table: "Servers_Servers", + column: "StarId"); + + migrationBuilder.CreateIndex( + name: "IX_Servers_ServerVariables_ServerId", + table: "Servers_ServerVariables", + column: "ServerId"); + + migrationBuilder.CreateIndex( + name: "IX_Servers_StarDockerImages_StarId", + table: "Servers_StarDockerImages", + column: "StarId"); + + migrationBuilder.CreateIndex( + name: "IX_Servers_StarVariables_StarId", + table: "Servers_StarVariables", + column: "StarId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Servers_Allocations"); + + migrationBuilder.DropTable( + name: "Servers_ServerBackups"); + + migrationBuilder.DropTable( + name: "Servers_ServerVariables"); + + migrationBuilder.DropTable( + name: "Servers_StarDockerImages"); + + migrationBuilder.DropTable( + name: "Servers_StarVariables"); + + migrationBuilder.DropTable( + name: "Servers_Servers"); + + migrationBuilder.DropTable( + name: "Servers_Nodes"); + + migrationBuilder.DropTable( + name: "Servers_Stars"); + } + } +} diff --git a/MoonlightServers.ApiServer/Database/Migrations/ServersDataContextModelSnapshot.cs b/MoonlightServers.ApiServer/Database/Migrations/ServersDataContextModelSnapshot.cs index b52522f..4589522 100644 --- a/MoonlightServers.ApiServer/Database/Migrations/ServersDataContextModelSnapshot.cs +++ b/MoonlightServers.ApiServer/Database/Migrations/ServersDataContextModelSnapshot.cs @@ -2,9 +2,9 @@ using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using MoonlightServers.ApiServer.Database; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable @@ -17,32 +17,31 @@ namespace MoonlightServers.ApiServer.Database.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasDefaultSchema("Servers") .HasAnnotation("ProductVersion", "8.0.11") - .HasAnnotation("Relational:MaxIdentifierLength", 64); + .HasAnnotation("Relational:MaxIdentifierLength", 63); - MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Allocation", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("IpAddress") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("NodeId") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("Port") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("ServerId") - .HasColumnType("int"); + .HasColumnType("integer"); b.HasKey("Id"); @@ -50,90 +49,90 @@ namespace MoonlightServers.ApiServer.Database.Migrations b.HasIndex("ServerId"); - b.ToTable("Allocations", "Servers"); + b.ToTable("Servers_Allocations", (string)null); }); modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Node", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("EnableDynamicFirewall") - .HasColumnType("tinyint(1)"); + .HasColumnType("boolean"); b.Property("EnableTransparentMode") - .HasColumnType("tinyint(1)"); + .HasColumnType("boolean"); b.Property("Fqdn") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("FtpPort") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("HttpPort") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("Name") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Token") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("UseSsl") - .HasColumnType("tinyint(1)"); + .HasColumnType("boolean"); b.HasKey("Id"); - b.ToTable("Nodes", "Servers"); + b.ToTable("Servers_Nodes", (string)null); }); modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Server", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Bandwidth") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("Cpu") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("Disk") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("DockerImageIndex") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("Memory") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("Name") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("NodeId") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("OwnerId") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("StarId") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("StartupOverride") - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("UseVirtualDisk") - .HasColumnType("tinyint(1)"); + .HasColumnType("boolean"); b.HasKey("Id"); @@ -141,209 +140,209 @@ namespace MoonlightServers.ApiServer.Database.Migrations b.HasIndex("StarId"); - b.ToTable("Servers", "Servers"); + b.ToTable("Servers_Servers", (string)null); }); modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.ServerBackup", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Completed") - .HasColumnType("tinyint(1)"); + .HasColumnType("boolean"); b.Property("CompletedAt") - .HasColumnType("datetime(6)"); + .HasColumnType("timestamp with time zone"); b.Property("CreatedAt") - .HasColumnType("datetime(6)"); + .HasColumnType("timestamp with time zone"); b.Property("ServerId") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("Size") .HasColumnType("bigint"); b.Property("Successful") - .HasColumnType("tinyint(1)"); + .HasColumnType("boolean"); b.HasKey("Id"); b.HasIndex("ServerId"); - b.ToTable("ServerBackups", "Servers"); + b.ToTable("Servers_ServerBackups", (string)null); }); modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.ServerVariable", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Key") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("ServerId") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("Value") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.HasKey("Id"); b.HasIndex("ServerId"); - b.ToTable("ServerVariables", "Servers"); + b.ToTable("Servers_ServerVariables", (string)null); }); modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Star", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("AllowDockerImageChange") - .HasColumnType("tinyint(1)"); + .HasColumnType("boolean"); b.Property("Author") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("DefaultDockerImage") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("DonateUrl") - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("InstallDockerImage") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("InstallScript") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("InstallShell") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Name") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("OnlineDetection") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("ParseConfiguration") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("RequiredAllocations") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("StartupCommand") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("StopCommand") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("UpdateUrl") - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Version") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.HasKey("Id"); - b.ToTable("Stars", "Servers"); + b.ToTable("Servers_Stars", (string)null); }); modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarDockerImage", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("AutoPulling") - .HasColumnType("tinyint(1)"); + .HasColumnType("boolean"); b.Property("DisplayName") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Identifier") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("StarId") - .HasColumnType("int"); + .HasColumnType("integer"); b.HasKey("Id"); b.HasIndex("StarId"); - b.ToTable("StarDockerImages", "Servers"); + b.ToTable("Servers_StarDockerImages", (string)null); }); modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.StarVariable", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); - MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("AllowEditing") - .HasColumnType("tinyint(1)"); + .HasColumnType("boolean"); b.Property("AllowViewing") - .HasColumnType("tinyint(1)"); + .HasColumnType("boolean"); b.Property("DefaultValue") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Description") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Filter") - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Key") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Name") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("StarId") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("Type") - .HasColumnType("int"); + .HasColumnType("integer"); b.HasKey("Id"); b.HasIndex("StarId"); - b.ToTable("StarVariables", "Servers"); + b.ToTable("Servers_StarVariables", (string)null); }); modelBuilder.Entity("MoonlightServers.ApiServer.Database.Entities.Allocation", b => diff --git a/MoonlightServers.ApiServer/Database/ServersDataContext.cs b/MoonlightServers.ApiServer/Database/ServersDataContext.cs index 91e8f20..ad28c7f 100644 --- a/MoonlightServers.ApiServer/Database/ServersDataContext.cs +++ b/MoonlightServers.ApiServer/Database/ServersDataContext.cs @@ -1,4 +1,5 @@ using Microsoft.EntityFrameworkCore; +using MoonCore.Extended.SingleDb; using Moonlight.ApiServer.Configuration; using Moonlight.ApiServer.Helpers; using MoonlightServers.ApiServer.Database.Entities; @@ -18,7 +19,15 @@ public class ServersDataContext : DatabaseContext public DbSet StarDockerImages { get; set; } public DbSet StarVariables { get; set; } - public ServersDataContext(AppConfiguration configuration) : base(configuration) + public ServersDataContext(AppConfiguration configuration) { + Options = new() + { + Host = configuration.Database.Host, + Port = configuration.Database.Port, + Username = configuration.Database.Username, + Password = configuration.Database.Password, + Database = configuration.Database.Database + }; } } \ No newline at end of file diff --git a/MoonlightServers.ApiServer/MoonlightServers.ApiServer.csproj b/MoonlightServers.ApiServer/MoonlightServers.ApiServer.csproj index eb0151c..373de23 100644 --- a/MoonlightServers.ApiServer/MoonlightServers.ApiServer.csproj +++ b/MoonlightServers.ApiServer/MoonlightServers.ApiServer.csproj @@ -4,6 +4,7 @@ net8.0 enable enable + Linux diff --git a/MoonlightServers.ApiServer/Program.cs b/MoonlightServers.ApiServer/Program.cs index 5608152..15dd10c 100644 --- a/MoonlightServers.ApiServer/Program.cs +++ b/MoonlightServers.ApiServer/Program.cs @@ -1,7 +1,35 @@ +using System.Text.Json; using Moonlight.ApiServer; +using Moonlight.ApiServer.Models; + +// Development Server Startup + +// This file is a small helper for development instances for moonlight. +// It calls the moonlight startup with the current project loaded as a plugin. +// This allows you to develop and debug projects without any hassle + +// !!! DO NOT HARDCORE ANY SECRETS HERE !!! var startup = new Startup(); -await startup.Run(args, [ - typeof(Program).Assembly -]); \ No newline at end of file +#region Creating virtual plugin manifest from plugin.json file + +// Read out content +var pluginManifestJson = await File.ReadAllTextAsync("../plugin.json"); + +// Parse to model +var pluginManifest = JsonSerializer.Deserialize(pluginManifestJson, new JsonSerializerOptions() +{ + PropertyNameCaseInsensitive = true +})!; + +// Clear assemblies as we are loading them using the additional assembly parameter +pluginManifest.Assemblies.Clear(); + +#endregion + +await startup.Run( + args, + [typeof(Program).Assembly], + [pluginManifest] +); \ No newline at end of file diff --git a/MoonlightServers.ApiServer/Startup/PluginStartup.cs b/MoonlightServers.ApiServer/Startup/PluginStartup.cs index 1e19dfc..17f8e20 100644 --- a/MoonlightServers.ApiServer/Startup/PluginStartup.cs +++ b/MoonlightServers.ApiServer/Startup/PluginStartup.cs @@ -1,27 +1,17 @@ using MoonCore.Extensions; -using Moonlight.ApiServer.Helpers; using Moonlight.ApiServer.Interfaces.Startup; -using Moonlight.ApiServer.Services; using MoonlightServers.ApiServer.Database; namespace MoonlightServers.ApiServer.Startup; public class PluginStartup : IPluginStartup { - private readonly BundleService BundleService; - - public PluginStartup(BundleService bundleService) - { - BundleService = bundleService; - } - public Task BuildApplication(IHostApplicationBuilder builder) { // Scan the current plugin assembly for di services builder.Services.AutoAddServices(); - - BundleService.BundleCss("css/MoonlightServers.min.css"); - BundleService.BundleCss("css/XtermBlazor.min.css"); + + builder.Services.AddDbContext(); return Task.CompletedTask; } @@ -29,13 +19,6 @@ public class PluginStartup : IPluginStartup public Task ConfigureApplication(IApplicationBuilder app) => Task.CompletedTask; - public Task ConfigureDatabase(DatabaseContextCollection collection) - { - collection.Add(); - - return Task.CompletedTask; - } - public Task ConfigureEndpoints(IEndpointRouteBuilder routeBuilder) => Task.CompletedTask; } \ No newline at end of file diff --git a/MoonlightServers.Frontend/Implementations/SidebarImplementation.cs b/MoonlightServers.Frontend/Implementations/SidebarImplementation.cs index e416f7f..cdea165 100644 --- a/MoonlightServers.Frontend/Implementations/SidebarImplementation.cs +++ b/MoonlightServers.Frontend/Implementations/SidebarImplementation.cs @@ -5,25 +5,26 @@ namespace MoonlightServers.Frontend.Implementations; public class SidebarImplementation : ISidebarItemProvider { - public SidebarItem[] Get() + public void ModifySidebar(List items) { - return - [ - new SidebarItem() - { - Name = "Servers", - Path = "/servers", - Icon = "icon-server", - Priority = 4 - }, - new SidebarItem() - { - Name = "Servers", - Path = "/admin/servers", - Icon = "icon-server", - Group = "Admin", - Priority = 4 - } - ]; + items.AddRange( + [ + new SidebarItem() + { + Name = "Servers", + Path = "/servers", + Icon = "icon-server", + Priority = 4 + }, + new SidebarItem() + { + Name = "Servers", + Path = "/admin/servers", + Icon = "icon-server", + Group = "Admin", + Priority = 4 + } + ] + ); } } \ No newline at end of file diff --git a/MoonlightServers.Frontend/Program.cs b/MoonlightServers.Frontend/Program.cs index 6def57a..21a691b 100644 --- a/MoonlightServers.Frontend/Program.cs +++ b/MoonlightServers.Frontend/Program.cs @@ -1,5 +1,13 @@ using Moonlight.Client; +// Development Client Startup + +// This file is a small helper for development instances for moonlight. +// It calls the moonlight startup with the current project loaded as a plugin. +// This allows you to develop and debug projects without any hassle + +// !!! DO NOT HARDCORE ANY SECRETS HERE !!! + var startup = new Startup(); await startup.Run(args, [ diff --git a/MoonlightServers.sln b/MoonlightServers.sln index 1eadb0a..881b1ad 100644 --- a/MoonlightServers.sln +++ b/MoonlightServers.sln @@ -10,6 +10,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoonlightServers.Daemon", " EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoonlightServers.DaemonShared", "MoonlightServers.DaemonShared\MoonlightServers.DaemonShared.csproj", "{15EBCC5D-2440-4B5B-A046-F8327E0C1CB8}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B20EF01B-C5D6-47E7-B0DF-143E85332513}" + ProjectSection(SolutionItems) = preProject + plugin.json = plugin.json + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/plugin.json b/plugin.json new file mode 100644 index 0000000..8e63bf6 --- /dev/null +++ b/plugin.json @@ -0,0 +1,18 @@ +{ + "id": "servers", + "name": "Servers", + "author": "Moonlight-Panel/Servers contributors", + "assemblies": { + "apiServer": ["MoonlightServers.ApiServer.dll"], + "client": ["MoonlightServers.Client.dll"] + }, + "bundledStyles": [ + "css/MoonlightServers.min.css", + "css/XtermBlazor.min.css" + ], + "scripts": [ + "js/XtermBlazor.min.js", + "js/addon-fit.js", + "js/moonlightServers.js" + ] +} \ No newline at end of file