NadekoBot/NadekoBot.Core/Migrations/20170122044958_waifus.cs
2017-09-30 00:46:33 +02:00

139 lines
5.5 KiB
C#

using Microsoft.EntityFrameworkCore.Migrations;
namespace NadekoBot.Migrations
{
public partial class waifus : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "DiscordUser",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
AvatarId = table.Column<string>(nullable: true),
Discriminator = table.Column<string>(nullable: true),
UserId = table.Column<ulong>(nullable: false),
Username = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_DiscordUser", x => x.Id);
table.UniqueConstraint("AK_DiscordUser_UserId", x => x.UserId);
});
migrationBuilder.CreateTable(
name: "WaifuInfo",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
AffinityId = table.Column<int>(nullable: true),
ClaimerId = table.Column<int>(nullable: true),
Price = table.Column<int>(nullable: false),
WaifuId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_WaifuInfo", x => x.Id);
table.ForeignKey(
name: "FK_WaifuInfo_DiscordUser_AffinityId",
column: x => x.AffinityId,
principalTable: "DiscordUser",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_WaifuInfo_DiscordUser_ClaimerId",
column: x => x.ClaimerId,
principalTable: "DiscordUser",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_WaifuInfo_DiscordUser_WaifuId",
column: x => x.WaifuId,
principalTable: "DiscordUser",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "WaifuUpdates",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
NewId = table.Column<int>(nullable: true),
OldId = table.Column<int>(nullable: true),
UpdateType = table.Column<int>(nullable: false),
UserId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_WaifuUpdates", x => x.Id);
table.ForeignKey(
name: "FK_WaifuUpdates_DiscordUser_NewId",
column: x => x.NewId,
principalTable: "DiscordUser",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_WaifuUpdates_DiscordUser_OldId",
column: x => x.OldId,
principalTable: "DiscordUser",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_WaifuUpdates_DiscordUser_UserId",
column: x => x.UserId,
principalTable: "DiscordUser",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_WaifuInfo_AffinityId",
table: "WaifuInfo",
column: "AffinityId");
migrationBuilder.CreateIndex(
name: "IX_WaifuInfo_ClaimerId",
table: "WaifuInfo",
column: "ClaimerId");
migrationBuilder.CreateIndex(
name: "IX_WaifuInfo_WaifuId",
table: "WaifuInfo",
column: "WaifuId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_WaifuUpdates_NewId",
table: "WaifuUpdates",
column: "NewId");
migrationBuilder.CreateIndex(
name: "IX_WaifuUpdates_OldId",
table: "WaifuUpdates",
column: "OldId");
migrationBuilder.CreateIndex(
name: "IX_WaifuUpdates_UserId",
table: "WaifuUpdates",
column: "UserId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "WaifuInfo");
migrationBuilder.DropTable(
name: "WaifuUpdates");
migrationBuilder.DropTable(
name: "DiscordUser");
}
}
}