Get less draconian with the migrations

This commit is contained in:
Jordan Brown
2020-04-11 22:17:01 -04:00
parent e1a53c2094
commit fa12f04615
14 changed files with 173 additions and 62 deletions
@@ -10,7 +10,7 @@ namespace Tgstation.Server.Api.Models
/// <summary>
/// The IRC channel name
/// </summary>
[StringLength(Limits.MaximumStringLength)]
[StringLength(Limits.MaximumIndexableStringLength)]
public string IrcChannel { get; set; }
/// <summary>
@@ -24,7 +24,6 @@ namespace Tgstation.Server.Api.Models
/// The path to where the <see cref="Instance"/> is located. Can only be changed while the <see cref="Instance"/> is offline. Must not exist when the instance is created
/// </summary>
[Required]
[StringLength(Limits.MaximumStringLength)]
public string Path { get; set; }
/// <summary>
@@ -17,7 +17,7 @@ namespace Tgstation.Server.Api.Models.Internal
/// The name of the connection
/// </summary>
[Required]
[StringLength(Limits.MaximumStringLength)]
[StringLength(Limits.MaximumIndexableStringLength)]
public string Name { get; set; }
/// <summary>
@@ -9,5 +9,10 @@
/// Length limit for strings in fields.
/// </summary>
public const int MaximumStringLength = 10000;
/// <summary>
/// Length limit for <see cref="Internal.ChatBot.Name"/>s.
/// </summary>
public const int MaximumIndexableStringLength = 100;
}
}
@@ -37,7 +37,7 @@ namespace Tgstation.Server.Host.Database.Migrations
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(10000);
.HasMaxLength(100);
b.Property<int>("Provider");
@@ -63,7 +63,7 @@ namespace Tgstation.Server.Host.Database.Migrations
.HasConversion(new ValueConverter<decimal, decimal>(v => default(decimal), v => default(decimal), new ConverterMappingHints(precision: 20, scale: 0)));
b.Property<string>("IrcChannel")
.HasMaxLength(10000);
.HasMaxLength(100);
b.Property<bool?>("IsAdminChannel")
.IsRequired();
@@ -207,8 +207,7 @@ namespace Tgstation.Server.Host.Database.Migrations
.IsRequired();
b.Property<string>("Path")
.IsRequired()
.HasMaxLength(10000);
.IsRequired();
b.HasKey("Id");
@@ -14,6 +14,14 @@ namespace Tgstation.Server.Host.Database.Migrations
if (migrationBuilder == null)
throw new ArgumentNullException(nameof(migrationBuilder));
migrationBuilder.DropForeignKey(
name: "FK_ChatBots_Instances_InstanceId",
table: "ChatBots");
migrationBuilder.DropIndex(
name: "IX_ChatChannels_ChatSettingsId_IrcChannel",
table: "ChatChannels");
migrationBuilder.DropIndex(
name: "IX_ChatBots_InstanceId",
table: "ChatBots");
@@ -36,17 +44,10 @@ namespace Tgstation.Server.Host.Database.Migrations
nullable: false,
oldClrType: typeof(string));
migrationBuilder.AlterColumn<string>(
name: "Path",
table: "Instances",
maxLength: 10000,
nullable: false,
oldClrType: typeof(string));
migrationBuilder.AlterColumn<string>(
name: "IrcChannel",
table: "ChatChannels",
maxLength: 10000,
maxLength: 100,
nullable: true,
oldClrType: typeof(string),
oldNullable: true);
@@ -61,7 +62,7 @@ namespace Tgstation.Server.Host.Database.Migrations
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "ChatBots",
maxLength: 10000,
maxLength: 100,
nullable: false,
oldClrType: typeof(string));
@@ -77,6 +78,21 @@ namespace Tgstation.Server.Host.Database.Migrations
table: "ChatBots",
columns: new[] { "InstanceId", "Name" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ChatChannels_ChatSettingsId_IrcChannel",
table: "ChatChannels",
columns: new[] { "ChatSettingsId", "IrcChannel" },
unique: true,
filter: "[IrcChannel] IS NOT NULL");
migrationBuilder.AddForeignKey(
name: "FK_ChatBots_Instances_InstanceId",
table: "ChatBots",
column: "InstanceId",
principalTable: "Instances",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
@@ -85,6 +101,14 @@ namespace Tgstation.Server.Host.Database.Migrations
if (migrationBuilder == null)
throw new ArgumentNullException(nameof(migrationBuilder));
migrationBuilder.DropForeignKey(
name: "FK_ChatBots_Instances_InstanceId",
table: "ChatBots");
migrationBuilder.DropIndex(
name: "IX_ChatChannels_ChatSettingsId_IrcChannel",
table: "ChatChannels");
migrationBuilder.DropIndex(
name: "IX_Users_SystemIdentifier",
table: "Users");
@@ -107,19 +131,12 @@ namespace Tgstation.Server.Host.Database.Migrations
oldClrType: typeof(string),
oldMaxLength: 40);
migrationBuilder.AlterColumn<string>(
name: "Path",
table: "Instances",
nullable: false,
oldClrType: typeof(string),
oldMaxLength: 10000);
migrationBuilder.AlterColumn<string>(
name: "IrcChannel",
table: "ChatChannels",
nullable: true,
oldClrType: typeof(string),
oldMaxLength: 10000,
oldMaxLength: 100,
oldNullable: true);
migrationBuilder.AlterColumn<int>(
@@ -133,7 +150,7 @@ namespace Tgstation.Server.Host.Database.Migrations
table: "ChatBots",
nullable: false,
oldClrType: typeof(string),
oldMaxLength: 10000);
oldMaxLength: 100);
migrationBuilder.CreateIndex(
name: "IX_ChatBots_InstanceId",
@@ -145,6 +162,21 @@ namespace Tgstation.Server.Host.Database.Migrations
table: "ChatBots",
column: "Name",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ChatChannels_ChatSettingsId_IrcChannel",
table: "ChatChannels",
columns: new[] { "ChatSettingsId", "IrcChannel" },
unique: true,
filter: "[IrcChannel] IS NOT NULL");
migrationBuilder.AddForeignKey(
name: "FK_ChatBots_Instances_InstanceId",
table: "ChatBots",
column: "InstanceId",
principalTable: "Instances",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}
@@ -33,7 +33,7 @@ namespace Tgstation.Server.Host.Database.Migrations
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(10000);
.HasMaxLength(100);
b.Property<int>("Provider");
@@ -58,7 +58,7 @@ namespace Tgstation.Server.Host.Database.Migrations
b.Property<ulong?>("DiscordChannelId");
b.Property<string>("IrcChannel")
.HasMaxLength(10000);
.HasMaxLength(100);
b.Property<bool?>("IsAdminChannel")
.IsRequired();
@@ -201,8 +201,7 @@ namespace Tgstation.Server.Host.Database.Migrations
.IsRequired();
b.Property<string>("Path")
.IsRequired()
.HasMaxLength(10000);
.IsRequired();
b.HasKey("Id");
@@ -14,6 +14,14 @@ namespace Tgstation.Server.Host.Database.Migrations
if (migrationBuilder == null)
throw new ArgumentNullException(nameof(migrationBuilder));
migrationBuilder.DropForeignKey(
name: "FK_ChatBots_Instances_InstanceId",
table: "ChatBots");
migrationBuilder.DropIndex(
name: "IX_ChatChannels_ChatSettingsId_IrcChannel",
table: "ChatChannels");
migrationBuilder.DropIndex(
name: "IX_ChatBots_InstanceId",
table: "ChatBots");
@@ -36,17 +44,10 @@ namespace Tgstation.Server.Host.Database.Migrations
nullable: false,
oldClrType: typeof(string));
migrationBuilder.AlterColumn<string>(
name: "Path",
table: "Instances",
maxLength: 10000,
nullable: false,
oldClrType: typeof(string));
migrationBuilder.AlterColumn<string>(
name: "IrcChannel",
table: "ChatChannels",
maxLength: 10000,
maxLength: 100,
nullable: true,
oldClrType: typeof(string),
oldNullable: true);
@@ -61,7 +62,7 @@ namespace Tgstation.Server.Host.Database.Migrations
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "ChatBots",
maxLength: 10000,
maxLength: 100,
nullable: false,
oldClrType: typeof(string));
@@ -76,6 +77,21 @@ namespace Tgstation.Server.Host.Database.Migrations
table: "ChatBots",
columns: new[] { "InstanceId", "Name" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ChatChannels_ChatSettingsId_IrcChannel",
table: "ChatChannels",
columns: new[] { "ChatSettingsId", "IrcChannel" },
unique: true,
filter: "[IrcChannel] IS NOT NULL");
migrationBuilder.AddForeignKey(
name: "FK_ChatBots_Instances_InstanceId",
table: "ChatBots",
column: "InstanceId",
principalTable: "Instances",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
@@ -84,6 +100,14 @@ namespace Tgstation.Server.Host.Database.Migrations
if (migrationBuilder == null)
throw new ArgumentNullException(nameof(migrationBuilder));
migrationBuilder.DropForeignKey(
name: "FK_ChatBots_Instances_InstanceId",
table: "ChatBots");
migrationBuilder.DropIndex(
name: "IX_ChatChannels_ChatSettingsId_IrcChannel",
table: "ChatChannels");
migrationBuilder.DropIndex(
name: "IX_Users_SystemIdentifier",
table: "Users");
@@ -106,19 +130,12 @@ namespace Tgstation.Server.Host.Database.Migrations
oldClrType: typeof(string),
oldMaxLength: 40);
migrationBuilder.AlterColumn<string>(
name: "Path",
table: "Instances",
nullable: false,
oldClrType: typeof(string),
oldMaxLength: 10000);
migrationBuilder.AlterColumn<string>(
name: "IrcChannel",
table: "ChatChannels",
nullable: true,
oldClrType: typeof(string),
oldMaxLength: 10000,
oldMaxLength: 100,
oldNullable: true);
migrationBuilder.AlterColumn<int>(
@@ -132,7 +149,7 @@ namespace Tgstation.Server.Host.Database.Migrations
table: "ChatBots",
nullable: false,
oldClrType: typeof(string),
oldMaxLength: 10000);
oldMaxLength: 100);
migrationBuilder.CreateIndex(
name: "IX_ChatBots_InstanceId",
@@ -144,6 +161,21 @@ namespace Tgstation.Server.Host.Database.Migrations
table: "ChatBots",
column: "Name",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ChatChannels_ChatSettingsId_IrcChannel",
table: "ChatChannels",
columns: new[] { "ChatSettingsId", "IrcChannel" },
unique: true,
filter: "[IrcChannel] IS NOT NULL");
migrationBuilder.AddForeignKey(
name: "FK_ChatBots_Instances_InstanceId",
table: "ChatBots",
column: "InstanceId",
principalTable: "Instances",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}
@@ -32,7 +32,7 @@ namespace Tgstation.Server.Host.Database.Migrations
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(10000);
.HasMaxLength(100);
b.Property<int>("Provider");
@@ -57,7 +57,7 @@ namespace Tgstation.Server.Host.Database.Migrations
b.Property<ulong?>("DiscordChannelId");
b.Property<string>("IrcChannel")
.HasMaxLength(10000);
.HasMaxLength(100);
b.Property<bool?>("IsAdminChannel")
.IsRequired();
@@ -14,6 +14,14 @@ namespace Tgstation.Server.Host.Database.Migrations
if (migrationBuilder == null)
throw new ArgumentNullException(nameof(migrationBuilder));
migrationBuilder.DropForeignKey(
name: "FK_ChatBots_Instances_InstanceId",
table: "ChatBots");
migrationBuilder.DropIndex(
name: "IX_ChatChannels_ChatSettingsId_IrcChannel",
table: "ChatChannels");
migrationBuilder.DropIndex(
name: "IX_ChatBots_InstanceId",
table: "ChatBots");
@@ -40,6 +48,21 @@ namespace Tgstation.Server.Host.Database.Migrations
table: "ChatBots",
columns: new[] { "InstanceId", "Name" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ChatChannels_ChatSettingsId_IrcChannel",
table: "ChatChannels",
columns: new[] { "ChatSettingsId", "IrcChannel" },
unique: true,
filter: "[IrcChannel] IS NOT NULL");
migrationBuilder.AddForeignKey(
name: "FK_ChatBots_Instances_InstanceId",
table: "ChatBots",
column: "InstanceId",
principalTable: "Instances",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
@@ -48,6 +71,14 @@ namespace Tgstation.Server.Host.Database.Migrations
if (migrationBuilder == null)
throw new ArgumentNullException(nameof(migrationBuilder));
migrationBuilder.DropForeignKey(
name: "FK_ChatBots_Instances_InstanceId",
table: "ChatBots");
migrationBuilder.DropIndex(
name: "IX_ChatChannels_ChatSettingsId_IrcChannel",
table: "ChatChannels");
migrationBuilder.DropIndex(
name: "IX_Users_SystemIdentifier",
table: "Users");
@@ -72,6 +103,21 @@ namespace Tgstation.Server.Host.Database.Migrations
table: "ChatBots",
column: "Name",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ChatChannels_ChatSettingsId_IrcChannel",
table: "ChatChannels",
columns: new[] { "ChatSettingsId", "IrcChannel" },
unique: true,
filter: "[IrcChannel] IS NOT NULL");
migrationBuilder.AddForeignKey(
name: "FK_ChatBots_Instances_InstanceId",
table: "ChatBots",
column: "InstanceId",
principalTable: "Instances",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}
@@ -34,7 +34,7 @@ namespace Tgstation.Server.Host.Database.Migrations
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(10000);
.HasMaxLength(100);
b.Property<int>("Provider");
@@ -59,7 +59,7 @@ namespace Tgstation.Server.Host.Database.Migrations
b.Property<ulong?>("DiscordChannelId");
b.Property<string>("IrcChannel")
.HasMaxLength(10000);
.HasMaxLength(100);
b.Property<bool?>("IsAdminChannel")
.IsRequired();
@@ -202,8 +202,7 @@ namespace Tgstation.Server.Host.Database.Migrations
.IsRequired();
b.Property<string>("Path")
.IsRequired()
.HasMaxLength(10000);
.IsRequired();
b.HasKey("Id");
@@ -38,7 +38,7 @@ namespace Tgstation.Server.Host.Database.Migrations
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(10000);
.HasMaxLength(100);
b.Property<int>("Provider");
@@ -64,7 +64,7 @@ namespace Tgstation.Server.Host.Database.Migrations
.HasConversion(new ValueConverter<decimal, decimal>(v => default(decimal), v => default(decimal), new ConverterMappingHints(precision: 20, scale: 0)));
b.Property<string>("IrcChannel")
.HasMaxLength(10000);
.HasMaxLength(100);
b.Property<bool?>("IsAdminChannel")
.IsRequired();
@@ -208,8 +208,7 @@ namespace Tgstation.Server.Host.Database.Migrations
.IsRequired();
b.Property<string>("Path")
.IsRequired()
.HasMaxLength(10000);
.IsRequired();
b.HasKey("Id");
@@ -33,7 +33,7 @@ namespace Tgstation.Server.Host.Database.Migrations
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(10000);
.HasMaxLength(100);
b.Property<int>("Provider");
@@ -58,7 +58,7 @@ namespace Tgstation.Server.Host.Database.Migrations
b.Property<ulong?>("DiscordChannelId");
b.Property<string>("IrcChannel")
.HasMaxLength(10000);
.HasMaxLength(100);
b.Property<bool?>("IsAdminChannel")
.IsRequired();
@@ -201,8 +201,7 @@ namespace Tgstation.Server.Host.Database.Migrations
.IsRequired();
b.Property<string>("Path")
.IsRequired()
.HasMaxLength(10000);
.IsRequired();
b.HasKey("Id");
@@ -60,7 +60,9 @@ namespace Tgstation.Server.Tests
String.Format(CultureInfo.InvariantCulture, "Database:DatabaseType={0}", databaseType),
String.Format(CultureInfo.InvariantCulture, "Database:ConnectionString={0}", connectionString),
String.Format(CultureInfo.InvariantCulture, "Database:DropDatabase={0}", true),
String.Format(CultureInfo.InvariantCulture, "General:SetupWizardMode={0}", SetupWizardMode.Never)
String.Format(CultureInfo.InvariantCulture, "General:SetupWizardMode={0}", SetupWizardMode.Never),
String.Format(CultureInfo.InvariantCulture, "General:InstanceLimit={0}", 10),
String.Format(CultureInfo.InvariantCulture, "General:UserLimit={0}", 150)
};
if (!String.IsNullOrEmpty(gitHubAccessToken))