continuity/Continuity.AuthServer/DB/Migrations/20231122064508_IndexingAndVariousOtherAnnotations.cs

206 lines
6.2 KiB
C#
Raw Permalink Normal View History

// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
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");
}
}