297 lines
12 KiB
C#
297 lines
12 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|||
|
|
|||
|
namespace NadekoBot.Migrations
|
|||
|
{
|
|||
|
public partial class xpandclubs : Migration
|
|||
|
{
|
|||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.AddColumn<int>(
|
|||
|
name: "XpMinutesTimeout",
|
|||
|
table: "BotConfig",
|
|||
|
nullable: false,
|
|||
|
defaultValue: 5)
|
|||
|
.Annotation("Sqlite:Autoincrement", true);
|
|||
|
|
|||
|
migrationBuilder.AddColumn<int>(
|
|||
|
name: "XpPerMessage",
|
|||
|
table: "BotConfig",
|
|||
|
nullable: false,
|
|||
|
defaultValue: 3)
|
|||
|
.Annotation("Sqlite:Autoincrement", true);
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Clubs",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(nullable: false)
|
|||
|
.Annotation("Sqlite:Autoincrement", true),
|
|||
|
DateAdded = table.Column<DateTime>(nullable: true),
|
|||
|
Discrim = table.Column<int>(nullable: false),
|
|||
|
ImageUrl = table.Column<string>(nullable: true),
|
|||
|
MinimumLevelReq = table.Column<int>(nullable: false),
|
|||
|
Name = table.Column<string>(maxLength: 20, nullable: false),
|
|||
|
OwnerId = table.Column<int>(nullable: false),
|
|||
|
Xp = table.Column<int>(nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Clubs", x => x.Id);
|
|||
|
table.UniqueConstraint("AK_Clubs_Name_Discrim", x => new { x.Name, x.Discrim });
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Clubs_DiscordUser_OwnerId",
|
|||
|
column: x => x.OwnerId,
|
|||
|
principalTable: "DiscordUser",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.Sql(MigrationQueries.UserClub);
|
|||
|
|
|||
|
migrationBuilder.AddColumn<DateTime>(
|
|||
|
name: "LastLevelUp",
|
|||
|
table: "DiscordUser",
|
|||
|
nullable: false,
|
|||
|
defaultValue: DateTime.UtcNow);
|
|||
|
|
|||
|
migrationBuilder.AddColumn<int>(
|
|||
|
name: "NotifyOnLevelUp",
|
|||
|
table: "DiscordUser",
|
|||
|
nullable: false,
|
|||
|
defaultValue: 0);
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "UserXpStats",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(nullable: false)
|
|||
|
.Annotation("Sqlite:Autoincrement", true),
|
|||
|
AwardedXp = table.Column<int>(nullable: false),
|
|||
|
DateAdded = table.Column<DateTime>(nullable: true),
|
|||
|
GuildId = table.Column<ulong>(nullable: false),
|
|||
|
LastLevelUp = table.Column<DateTime>(nullable: false, defaultValue: new DateTime(2017, 9, 9, 1, 7, 29, 858, DateTimeKind.Local)),
|
|||
|
NotifyOnLevelUp = table.Column<int>(nullable: false),
|
|||
|
UserId = table.Column<ulong>(nullable: false),
|
|||
|
Xp = table.Column<int>(nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_UserXpStats", x => x.Id);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "XpSettings",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(nullable: false)
|
|||
|
.Annotation("Sqlite:Autoincrement", true),
|
|||
|
DateAdded = table.Column<DateTime>(nullable: true),
|
|||
|
GuildConfigId = table.Column<int>(nullable: false),
|
|||
|
NotifyMessage = table.Column<string>(nullable: true),
|
|||
|
ServerExcluded = table.Column<bool>(nullable: false),
|
|||
|
XpRoleRewardExclusive = table.Column<bool>(nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_XpSettings", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_XpSettings_GuildConfigs_GuildConfigId",
|
|||
|
column: x => x.GuildConfigId,
|
|||
|
principalTable: "GuildConfigs",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "ClubApplicants",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
ClubId = table.Column<int>(nullable: false),
|
|||
|
UserId = table.Column<int>(nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_ClubApplicants", x => new { x.ClubId, x.UserId });
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_ClubApplicants_Clubs_ClubId",
|
|||
|
column: x => x.ClubId,
|
|||
|
principalTable: "Clubs",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_ClubApplicants_DiscordUser_UserId",
|
|||
|
column: x => x.UserId,
|
|||
|
principalTable: "DiscordUser",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "ClubBans",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
ClubId = table.Column<int>(nullable: false),
|
|||
|
UserId = table.Column<int>(nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_ClubBans", x => new { x.ClubId, x.UserId });
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_ClubBans_Clubs_ClubId",
|
|||
|
column: x => x.ClubId,
|
|||
|
principalTable: "Clubs",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_ClubBans_DiscordUser_UserId",
|
|||
|
column: x => x.UserId,
|
|||
|
principalTable: "DiscordUser",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "ExcludedItem",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(nullable: false)
|
|||
|
.Annotation("Sqlite:Autoincrement", true),
|
|||
|
DateAdded = table.Column<DateTime>(nullable: true),
|
|||
|
ItemId = table.Column<ulong>(nullable: false),
|
|||
|
ItemType = table.Column<int>(nullable: false),
|
|||
|
XpSettingsId = table.Column<int>(nullable: true)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_ExcludedItem", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_ExcludedItem_XpSettings_XpSettingsId",
|
|||
|
column: x => x.XpSettingsId,
|
|||
|
principalTable: "XpSettings",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Restrict);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "XpRoleReward",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(nullable: false)
|
|||
|
.Annotation("Sqlite:Autoincrement", true),
|
|||
|
DateAdded = table.Column<DateTime>(nullable: true),
|
|||
|
Level = table.Column<int>(nullable: false),
|
|||
|
RoleId = table.Column<ulong>(nullable: false),
|
|||
|
XpSettingsId = table.Column<int>(nullable: true)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_XpRoleReward", x => x.Id);
|
|||
|
table.UniqueConstraint("AK_XpRoleReward_Level", x => x.Level);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_XpRoleReward_XpSettings_XpSettingsId",
|
|||
|
column: x => x.XpSettingsId,
|
|||
|
principalTable: "XpSettings",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Restrict);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_DiscordUser_ClubId",
|
|||
|
table: "DiscordUser",
|
|||
|
column: "ClubId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_ClubApplicants_UserId",
|
|||
|
table: "ClubApplicants",
|
|||
|
column: "UserId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_ClubBans_UserId",
|
|||
|
table: "ClubBans",
|
|||
|
column: "UserId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Clubs_OwnerId",
|
|||
|
table: "Clubs",
|
|||
|
column: "OwnerId",
|
|||
|
unique: true);
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_ExcludedItem_XpSettingsId",
|
|||
|
table: "ExcludedItem",
|
|||
|
column: "XpSettingsId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_UserXpStats_UserId_GuildId",
|
|||
|
table: "UserXpStats",
|
|||
|
columns: new[] { "UserId", "GuildId" },
|
|||
|
unique: true);
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_XpRoleReward_XpSettingsId",
|
|||
|
table: "XpRoleReward",
|
|||
|
column: "XpSettingsId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_XpSettings_GuildConfigId",
|
|||
|
table: "XpSettings",
|
|||
|
column: "GuildConfigId",
|
|||
|
unique: true);
|
|||
|
}
|
|||
|
|
|||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.DropForeignKey(
|
|||
|
name: "FK_DiscordUser_Clubs_ClubId",
|
|||
|
table: "DiscordUser");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "ClubApplicants");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "ClubBans");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "ExcludedItem");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "UserXpStats");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "XpRoleReward");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Clubs");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "XpSettings");
|
|||
|
|
|||
|
migrationBuilder.DropIndex(
|
|||
|
name: "IX_DiscordUser_ClubId",
|
|||
|
table: "DiscordUser");
|
|||
|
|
|||
|
migrationBuilder.DropColumn(
|
|||
|
name: "ClubId",
|
|||
|
table: "DiscordUser");
|
|||
|
|
|||
|
migrationBuilder.DropColumn(
|
|||
|
name: "LastLevelUp",
|
|||
|
table: "DiscordUser");
|
|||
|
|
|||
|
migrationBuilder.DropColumn(
|
|||
|
name: "NotifyOnLevelUp",
|
|||
|
table: "DiscordUser");
|
|||
|
|
|||
|
migrationBuilder.DropColumn(
|
|||
|
name: "XpMinutesTimeout",
|
|||
|
table: "BotConfig");
|
|||
|
|
|||
|
migrationBuilder.DropColumn(
|
|||
|
name: "XpPerMessage",
|
|||
|
table: "BotConfig");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|