Switch Byond column names to Engine in database

This commit is contained in:
Jordan Dominion
2023-10-21 11:50:01 -04:00
parent 186d5d68dc
commit 73fa2ee225
16 changed files with 4706 additions and 32 deletions
@@ -25,6 +25,12 @@ namespace Tgstation.Server.Api.Models.Internal
[Required]
public InstancePermissionSetRights? InstancePermissionSetRights { get; set; }
/// <summary>
/// The <see cref="Rights.EngineRights"/> of the <see cref="InstancePermissionSet"/>.
/// </summary>
[Required]
public EngineRights? EngineRights { get; set; }
/// <summary>
/// The legacy <see cref="Rights.EngineRights"/> of the <see cref="InstancePermissionSet"/>.
/// </summary>
@@ -33,12 +39,6 @@ namespace Tgstation.Server.Api.Models.Internal
[NotMapped]
public EngineRights? ByondRights { get; set; }
/// <summary>
/// The <see cref="Rights.EngineRights"/> of the <see cref="InstancePermissionSet"/>.
/// </summary>
[Required]
public virtual EngineRights? EngineRights { get; set; }
/// <summary>
/// The <see cref="Rights.DreamDaemonRights"/> of the <see cref="InstancePermissionSet"/>.
/// </summary>
@@ -378,22 +378,22 @@ namespace Tgstation.Server.Host.Database
/// <summary>
/// Used by unit tests to remind us to setup the correct MSSQL migration downgrades.
/// </summary>
internal static readonly Type MSLatestMigration = typeof(MSAddMapThreads);
internal static readonly Type MSLatestMigration = typeof(MSRenameByondColumnsToEngine);
/// <summary>
/// Used by unit tests to remind us to setup the correct MYSQL migration downgrades.
/// </summary>
internal static readonly Type MYLatestMigration = typeof(MYAddMapThreads);
internal static readonly Type MYLatestMigration = typeof(MYRenameByondColumnsToEngine);
/// <summary>
/// Used by unit tests to remind us to setup the correct PostgresSQL migration downgrades.
/// </summary>
internal static readonly Type PGLatestMigration = typeof(PGAddMapThreads);
internal static readonly Type PGLatestMigration = typeof(PGRenameByondColumnsToEngine);
/// <summary>
/// Used by unit tests to remind us to setup the correct SQLite migration downgrades.
/// </summary>
internal static readonly Type SLLatestMigration = typeof(SLAddMapThreads);
internal static readonly Type SLLatestMigration = typeof(SLRenameByondColumnsToEngine);
/// <inheritdoc />
#pragma warning disable CA1502 // Cyclomatic complexity
@@ -422,6 +422,16 @@ namespace Tgstation.Server.Host.Database
string BadDatabaseType() => throw new ArgumentException($"Invalid DatabaseType: {currentDatabaseType}", nameof(currentDatabaseType));
if (targetVersion < new Version(6, 0, 0))
targetMigration = currentDatabaseType switch
{
DatabaseType.MySql => nameof(MYAddMapThreads),
DatabaseType.PostgresSql => nameof(PGAddMapThreads),
DatabaseType.SqlServer => nameof(MSAddMapThreads),
DatabaseType.Sqlite => nameof(SLAddMapThreads),
_ => BadDatabaseType(),
};
if (targetVersion < new Version(5, 13, 0))
targetMigration = currentDatabaseType switch
{
@@ -0,0 +1,44 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Tgstation.Server.Host.Database.Migrations
{
/// <inheritdoc />
public partial class MSRenameByondColumnsToEngine : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
ArgumentNullException.ThrowIfNull(migrationBuilder);
migrationBuilder.RenameColumn(
name: "ByondRights",
table: "InstancePermissionSets",
newName: "EngineRights");
migrationBuilder.RenameColumn(
name: "ByondVersion",
table: "CompileJobs",
newName: "EngineVersion");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
ArgumentNullException.ThrowIfNull(migrationBuilder);
migrationBuilder.RenameColumn(
name: "EngineRights",
table: "InstancePermissionSets",
newName: "ByondRights");
migrationBuilder.RenameColumn(
name: "EngineVersion",
table: "CompileJobs",
newName: "ByondVersion");
}
}
}
@@ -0,0 +1,44 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Tgstation.Server.Host.Database.Migrations
{
/// <inheritdoc />
public partial class MYRenameByondColumnsToEngine : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
ArgumentNullException.ThrowIfNull(migrationBuilder);
migrationBuilder.RenameColumn(
name: "ByondRights",
table: "InstancePermissionSets",
newName: "EngineRights");
migrationBuilder.RenameColumn(
name: "ByondVersion",
table: "CompileJobs",
newName: "EngineVersion");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
ArgumentNullException.ThrowIfNull(migrationBuilder);
migrationBuilder.RenameColumn(
name: "EngineRights",
table: "InstancePermissionSets",
newName: "ByondRights");
migrationBuilder.RenameColumn(
name: "EngineVersion",
table: "CompileJobs",
newName: "ByondVersion");
}
}
}
@@ -0,0 +1,242 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Tgstation.Server.Host.Database.Migrations
{
/// <inheritdoc />
public partial class PGRenameByondColumnsToEngine : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
ArgumentNullException.ThrowIfNull(migrationBuilder);
migrationBuilder.RenameColumn(
name: "ByondRights",
table: "InstancePermissionSets",
newName: "EngineRights");
migrationBuilder.RenameColumn(
name: "ByondVersion",
table: "CompileJobs",
newName: "EngineVersion");
migrationBuilder.AlterColumn<decimal>(
name: "InstanceManagerRights",
table: "PermissionSets",
type: "numeric(20,0)",
nullable: false,
oldClrType: typeof(decimal),
oldType: "numeric(20)");
migrationBuilder.AlterColumn<decimal>(
name: "AdministrationRights",
table: "PermissionSets",
type: "numeric(20,0)",
nullable: false,
oldClrType: typeof(decimal),
oldType: "numeric(20)");
migrationBuilder.AlterColumn<decimal>(
name: "CancelRightsType",
table: "Jobs",
type: "numeric(20,0)",
nullable: true,
oldClrType: typeof(decimal),
oldType: "numeric(20)",
oldNullable: true);
migrationBuilder.AlterColumn<decimal>(
name: "CancelRight",
table: "Jobs",
type: "numeric(20,0)",
nullable: true,
oldClrType: typeof(decimal),
oldType: "numeric(20)",
oldNullable: true);
migrationBuilder.AlterColumn<decimal>(
name: "RepositoryRights",
table: "InstancePermissionSets",
type: "numeric(20,0)",
nullable: false,
oldClrType: typeof(decimal),
oldType: "numeric(20)");
migrationBuilder.AlterColumn<decimal>(
name: "InstancePermissionSetRights",
table: "InstancePermissionSets",
type: "numeric(20,0)",
nullable: false,
oldClrType: typeof(decimal),
oldType: "numeric(20)");
migrationBuilder.AlterColumn<decimal>(
name: "DreamMakerRights",
table: "InstancePermissionSets",
type: "numeric(20,0)",
nullable: false,
oldClrType: typeof(decimal),
oldType: "numeric(20)");
migrationBuilder.AlterColumn<decimal>(
name: "DreamDaemonRights",
table: "InstancePermissionSets",
type: "numeric(20,0)",
nullable: false,
oldClrType: typeof(decimal),
oldType: "numeric(20)");
migrationBuilder.AlterColumn<decimal>(
name: "ConfigurationRights",
table: "InstancePermissionSets",
type: "numeric(20,0)",
nullable: false,
oldClrType: typeof(decimal),
oldType: "numeric(20)");
migrationBuilder.AlterColumn<decimal>(
name: "ChatBotRights",
table: "InstancePermissionSets",
type: "numeric(20,0)",
nullable: false,
oldClrType: typeof(decimal),
oldType: "numeric(20)");
migrationBuilder.AlterColumn<decimal>(
name: "EngineRights",
table: "InstancePermissionSets",
type: "numeric(20,0)",
nullable: false,
oldClrType: typeof(decimal),
oldType: "numeric(20)");
migrationBuilder.AlterColumn<decimal>(
name: "DiscordChannelId",
table: "ChatChannels",
type: "numeric(20,0)",
nullable: true,
oldClrType: typeof(decimal),
oldType: "numeric(20)",
oldNullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
ArgumentNullException.ThrowIfNull(migrationBuilder);
migrationBuilder.RenameColumn(
name: "EngineRights",
table: "InstancePermissionSets",
newName: "ByondRights");
migrationBuilder.RenameColumn(
name: "EngineVersion",
table: "CompileJobs",
newName: "ByondVersion");
migrationBuilder.AlterColumn<decimal>(
name: "InstanceManagerRights",
table: "PermissionSets",
type: "numeric(20)",
nullable: false,
oldClrType: typeof(decimal),
oldType: "numeric(20,0)");
migrationBuilder.AlterColumn<decimal>(
name: "AdministrationRights",
table: "PermissionSets",
type: "numeric(20)",
nullable: false,
oldClrType: typeof(decimal),
oldType: "numeric(20,0)");
migrationBuilder.AlterColumn<decimal>(
name: "CancelRightsType",
table: "Jobs",
type: "numeric(20)",
nullable: true,
oldClrType: typeof(decimal),
oldType: "numeric(20,0)",
oldNullable: true);
migrationBuilder.AlterColumn<decimal>(
name: "CancelRight",
table: "Jobs",
type: "numeric(20)",
nullable: true,
oldClrType: typeof(decimal),
oldType: "numeric(20,0)",
oldNullable: true);
migrationBuilder.AlterColumn<decimal>(
name: "RepositoryRights",
table: "InstancePermissionSets",
type: "numeric(20)",
nullable: false,
oldClrType: typeof(decimal),
oldType: "numeric(20,0)");
migrationBuilder.AlterColumn<decimal>(
name: "InstancePermissionSetRights",
table: "InstancePermissionSets",
type: "numeric(20)",
nullable: false,
oldClrType: typeof(decimal),
oldType: "numeric(20,0)");
migrationBuilder.AlterColumn<decimal>(
name: "DreamMakerRights",
table: "InstancePermissionSets",
type: "numeric(20)",
nullable: false,
oldClrType: typeof(decimal),
oldType: "numeric(20,0)");
migrationBuilder.AlterColumn<decimal>(
name: "DreamDaemonRights",
table: "InstancePermissionSets",
type: "numeric(20)",
nullable: false,
oldClrType: typeof(decimal),
oldType: "numeric(20,0)");
migrationBuilder.AlterColumn<decimal>(
name: "ConfigurationRights",
table: "InstancePermissionSets",
type: "numeric(20)",
nullable: false,
oldClrType: typeof(decimal),
oldType: "numeric(20,0)");
migrationBuilder.AlterColumn<decimal>(
name: "ChatBotRights",
table: "InstancePermissionSets",
type: "numeric(20)",
nullable: false,
oldClrType: typeof(decimal),
oldType: "numeric(20,0)");
migrationBuilder.AlterColumn<decimal>(
name: "ByondRights",
table: "InstancePermissionSets",
type: "numeric(20)",
nullable: false,
oldClrType: typeof(decimal),
oldType: "numeric(20,0)");
migrationBuilder.AlterColumn<decimal>(
name: "DiscordChannelId",
table: "ChatChannels",
type: "numeric(20)",
nullable: true,
oldClrType: typeof(decimal),
oldType: "numeric(20,0)",
oldNullable: true);
}
}
}
@@ -0,0 +1,44 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Tgstation.Server.Host.Database.Migrations
{
/// <inheritdoc />
public partial class SLRenameByondColumnsToEngine : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
ArgumentNullException.ThrowIfNull(migrationBuilder);
migrationBuilder.RenameColumn(
name: "ByondRights",
table: "InstancePermissionSets",
newName: "EngineRights");
migrationBuilder.RenameColumn(
name: "ByondVersion",
table: "CompileJobs",
newName: "EngineVersion");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
ArgumentNullException.ThrowIfNull(migrationBuilder);
migrationBuilder.RenameColumn(
name: "EngineRights",
table: "InstancePermissionSets",
newName: "ByondRights");
migrationBuilder.RenameColumn(
name: "EngineVersion",
table: "CompileJobs",
newName: "ByondVersion");
}
}
}
@@ -16,7 +16,7 @@ namespace Tgstation.Server.Host.Database.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.7")
.HasAnnotation("ProductVersion", "8.0.0-rc.1.23419.6")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Tgstation.Server.Host.Models.ChatBot", b =>
@@ -121,7 +121,8 @@ namespace Tgstation.Server.Host.Database.Migrations
b.Property<string>("ByondVersion")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("longtext")
.HasColumnName("EngineVersion");
MySqlPropertyBuilderExtensions.HasCharSet(b.Property<string>("ByondVersion"), "utf8mb4");
@@ -344,7 +345,8 @@ namespace Tgstation.Server.Host.Database.Migrations
.HasColumnType("bigint");
b.Property<ulong>("ByondRights")
.HasColumnType("bigint unsigned");
.HasColumnType("bigint unsigned")
.HasColumnName("EngineRights");
b.Property<ulong>("ChatBotRights")
.HasColumnType("bigint unsigned");
@@ -16,7 +16,7 @@ namespace Tgstation.Server.Host.Database.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.7")
.HasAnnotation("ProductVersion", "8.0.0-rc.1.23419.6")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
@@ -121,7 +121,8 @@ namespace Tgstation.Server.Host.Database.Migrations
b.Property<string>("ByondVersion")
.IsRequired()
.HasColumnType("text");
.HasColumnType("text")
.HasColumnName("EngineVersion");
b.Property<int?>("DMApiMajorVersion")
.HasColumnType("integer");
@@ -326,7 +327,8 @@ namespace Tgstation.Server.Host.Database.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<decimal>("ByondRights")
.HasColumnType("numeric(20,0)");
.HasColumnType("numeric(20,0)")
.HasColumnName("EngineRights");
b.Property<decimal>("ChatBotRights")
.HasColumnType("numeric(20,0)");
@@ -16,7 +16,7 @@ namespace Tgstation.Server.Host.Database.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.7")
.HasAnnotation("ProductVersion", "8.0.0-rc.1.23419.6")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
@@ -123,7 +123,8 @@ namespace Tgstation.Server.Host.Database.Migrations
b.Property<string>("ByondVersion")
.IsRequired()
.HasColumnType("nvarchar(max)");
.HasColumnType("nvarchar(max)")
.HasColumnName("EngineVersion");
b.Property<int?>("DMApiMajorVersion")
.HasColumnType("int");
@@ -329,7 +330,8 @@ namespace Tgstation.Server.Host.Database.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<decimal>("ByondRights")
.HasColumnType("decimal(20,0)");
.HasColumnType("decimal(20,0)")
.HasColumnName("EngineRights");
b.Property<decimal>("ChatBotRights")
.HasColumnType("decimal(20,0)");
@@ -15,7 +15,7 @@ namespace Tgstation.Server.Host.Database.Migrations
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.7");
modelBuilder.HasAnnotation("ProductVersion", "8.0.0-rc.1.23419.6");
modelBuilder.Entity("Tgstation.Server.Host.Models.ChatBot", b =>
{
@@ -113,7 +113,8 @@ namespace Tgstation.Server.Host.Database.Migrations
b.Property<string>("ByondVersion")
.IsRequired()
.HasColumnType("TEXT");
.HasColumnType("TEXT")
.HasColumnName("EngineVersion");
b.Property<int?>("DMApiMajorVersion")
.HasColumnType("INTEGER");
@@ -318,7 +319,8 @@ namespace Tgstation.Server.Host.Database.Migrations
.HasColumnType("INTEGER");
b.Property<ulong>("ByondRights")
.HasColumnType("INTEGER");
.HasColumnType("INTEGER")
.HasColumnName("EngineRights");
b.Property<ulong>("ChatBotRights")
.HasColumnType("INTEGER");
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Tgstation.Server.Api.Models;
using Tgstation.Server.Api.Models.Response;
@@ -30,6 +31,7 @@ namespace Tgstation.Server.Host.Models
/// The <see cref="Version"/> the <see cref="CompileJob"/> was made with in string form.
/// </summary>
[Required]
[Column("EngineVersion")]
public string ByondVersion { get; set; }
/// <summary>
@@ -1,8 +1,6 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Tgstation.Server.Api.Models.Response;
using Tgstation.Server.Api.Rights;
namespace Tgstation.Server.Host.Models
{
@@ -31,14 +29,6 @@ namespace Tgstation.Server.Host.Models
[Required]
public PermissionSet PermissionSet { get; set; }
/// <inheritdoc />
[Column("ByondRights")]
public override EngineRights? EngineRights
{
get => base.EngineRights;
set => base.EngineRights = value;
}
/// <inheritdoc />
public InstancePermissionSetResponse ToApi() => new InstancePermissionSetResponse
{