2024-02-07 15:40:36 +00:00
|
|
|
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
|
2023-11-22 06:59:08 +00:00
|
|
|
|
|
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
|
|
|
|
#nullable disable
|
|
|
|
|
|
|
|
namespace Server.DB.Migrations;
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
public partial class IndexingAndVariousOtherAnnotations : Migration
|
|
|
|
{
|
|
|
|
/// <inheritdoc />
|
|
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
|
|
{
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
|
|
name: "FK_Characters_Accounts_AccountId",
|
|
|
|
table: "Characters");
|
|
|
|
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
|
|
name: "FK_Characters_Guilds_GuildId",
|
|
|
|
table: "Characters");
|
|
|
|
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
|
|
name: "FK_GuildMember_Characters_CharacterId",
|
|
|
|
table: "GuildMember");
|
|
|
|
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
|
|
name: "FK_GuildMember_Guilds_GuildId",
|
|
|
|
table: "GuildMember");
|
|
|
|
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
|
|
name: "Name",
|
|
|
|
table: "Guilds",
|
|
|
|
type: "character varying(16)",
|
|
|
|
maxLength: 16,
|
|
|
|
nullable: true,
|
|
|
|
oldClrType: typeof(string),
|
|
|
|
oldType: "text",
|
|
|
|
oldNullable: true);
|
|
|
|
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
|
|
name: "Name",
|
|
|
|
table: "Characters",
|
|
|
|
type: "character varying(20)",
|
|
|
|
maxLength: 20,
|
|
|
|
nullable: true,
|
|
|
|
oldClrType: typeof(string),
|
|
|
|
oldType: "varchar(20)",
|
|
|
|
oldMaxLength: 20,
|
|
|
|
oldNullable: true);
|
|
|
|
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
|
|
name: "Username",
|
|
|
|
table: "Accounts",
|
|
|
|
type: "character varying(20)",
|
|
|
|
maxLength: 20,
|
|
|
|
nullable: true,
|
|
|
|
oldClrType: typeof(string),
|
|
|
|
oldType: "varchar(20)",
|
|
|
|
oldMaxLength: 20,
|
|
|
|
oldNullable: true);
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
name: "IX_Guilds_Id",
|
|
|
|
table: "Guilds",
|
|
|
|
column: "Id",
|
|
|
|
unique: true);
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
name: "IX_Guilds_Name",
|
|
|
|
table: "Guilds",
|
|
|
|
column: "Name",
|
|
|
|
unique: true);
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
name: "IX_GuildMember_Id",
|
|
|
|
table: "GuildMember",
|
|
|
|
column: "Id",
|
|
|
|
unique: true);
|
|
|
|
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
|
|
name: "FK_Characters_Accounts_AccountId",
|
|
|
|
table: "Characters",
|
|
|
|
column: "AccountId",
|
|
|
|
principalTable: "Accounts",
|
|
|
|
principalColumn: "Id",
|
|
|
|
onDelete: ReferentialAction.Restrict);
|
|
|
|
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
|
|
name: "FK_Characters_Guilds_GuildId",
|
|
|
|
table: "Characters",
|
|
|
|
column: "GuildId",
|
|
|
|
principalTable: "Guilds",
|
|
|
|
principalColumn: "Id",
|
|
|
|
onDelete: ReferentialAction.Restrict);
|
|
|
|
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
|
|
name: "FK_GuildMember_Characters_CharacterId",
|
|
|
|
table: "GuildMember",
|
|
|
|
column: "CharacterId",
|
|
|
|
principalTable: "Characters",
|
|
|
|
principalColumn: "Id",
|
|
|
|
onDelete: ReferentialAction.Restrict);
|
|
|
|
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
|
|
name: "FK_GuildMember_Guilds_GuildId",
|
|
|
|
table: "GuildMember",
|
|
|
|
column: "GuildId",
|
|
|
|
principalTable: "Guilds",
|
|
|
|
principalColumn: "Id",
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
|
|
{
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
|
|
name: "FK_Characters_Accounts_AccountId",
|
|
|
|
table: "Characters");
|
|
|
|
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
|
|
name: "FK_Characters_Guilds_GuildId",
|
|
|
|
table: "Characters");
|
|
|
|
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
|
|
name: "FK_GuildMember_Characters_CharacterId",
|
|
|
|
table: "GuildMember");
|
|
|
|
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
|
|
name: "FK_GuildMember_Guilds_GuildId",
|
|
|
|
table: "GuildMember");
|
|
|
|
|
|
|
|
migrationBuilder.DropIndex(
|
|
|
|
name: "IX_Guilds_Id",
|
|
|
|
table: "Guilds");
|
|
|
|
|
|
|
|
migrationBuilder.DropIndex(
|
|
|
|
name: "IX_Guilds_Name",
|
|
|
|
table: "Guilds");
|
|
|
|
|
|
|
|
migrationBuilder.DropIndex(
|
|
|
|
name: "IX_GuildMember_Id",
|
|
|
|
table: "GuildMember");
|
|
|
|
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
|
|
name: "Name",
|
|
|
|
table: "Guilds",
|
|
|
|
type: "text",
|
|
|
|
nullable: true,
|
|
|
|
oldClrType: typeof(string),
|
|
|
|
oldType: "character varying(16)",
|
|
|
|
oldMaxLength: 16,
|
|
|
|
oldNullable: true);
|
|
|
|
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
|
|
name: "Name",
|
|
|
|
table: "Characters",
|
|
|
|
type: "varchar(20)",
|
|
|
|
maxLength: 20,
|
|
|
|
nullable: true,
|
|
|
|
oldClrType: typeof(string),
|
|
|
|
oldType: "character varying(20)",
|
|
|
|
oldMaxLength: 20,
|
|
|
|
oldNullable: true);
|
|
|
|
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
|
|
name: "Username",
|
|
|
|
table: "Accounts",
|
|
|
|
type: "varchar(20)",
|
|
|
|
maxLength: 20,
|
|
|
|
nullable: true,
|
|
|
|
oldClrType: typeof(string),
|
|
|
|
oldType: "character varying(20)",
|
|
|
|
oldMaxLength: 20,
|
|
|
|
oldNullable: true);
|
|
|
|
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
|
|
name: "FK_Characters_Accounts_AccountId",
|
|
|
|
table: "Characters",
|
|
|
|
column: "AccountId",
|
|
|
|
principalTable: "Accounts",
|
|
|
|
principalColumn: "Id");
|
|
|
|
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
|
|
name: "FK_Characters_Guilds_GuildId",
|
|
|
|
table: "Characters",
|
|
|
|
column: "GuildId",
|
|
|
|
principalTable: "Guilds",
|
|
|
|
principalColumn: "Id");
|
|
|
|
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
|
|
name: "FK_GuildMember_Characters_CharacterId",
|
|
|
|
table: "GuildMember",
|
|
|
|
column: "CharacterId",
|
|
|
|
principalTable: "Characters",
|
|
|
|
principalColumn: "Id");
|
|
|
|
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
|
|
name: "FK_GuildMember_Guilds_GuildId",
|
|
|
|
table: "GuildMember",
|
|
|
|
column: "GuildId",
|
|
|
|
principalTable: "Guilds",
|
|
|
|
principalColumn: "Id");
|
|
|
|
}
|
|
|
|
}
|