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( name: "XpMinutesTimeout", table: "BotConfig", nullable: false, defaultValue: 5) .Annotation("Sqlite:Autoincrement", true); migrationBuilder.AddColumn( name: "XpPerMessage", table: "BotConfig", nullable: false, defaultValue: 3) .Annotation("Sqlite:Autoincrement", true); migrationBuilder.CreateTable( name: "Clubs", columns: table => new { Id = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true), DateAdded = table.Column(nullable: true), Discrim = table.Column(nullable: false), ImageUrl = table.Column(nullable: true), MinimumLevelReq = table.Column(nullable: false), Name = table.Column(maxLength: 20, nullable: false), OwnerId = table.Column(nullable: false), Xp = table.Column(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( name: "LastLevelUp", table: "DiscordUser", nullable: false, defaultValue: DateTime.UtcNow); migrationBuilder.AddColumn( name: "NotifyOnLevelUp", table: "DiscordUser", nullable: false, defaultValue: 0); migrationBuilder.CreateTable( name: "UserXpStats", columns: table => new { Id = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true), AwardedXp = table.Column(nullable: false), DateAdded = table.Column(nullable: true), GuildId = table.Column(nullable: false), LastLevelUp = table.Column(nullable: false, defaultValue: new DateTime(2017, 9, 9, 1, 7, 29, 858, DateTimeKind.Local)), NotifyOnLevelUp = table.Column(nullable: false), UserId = table.Column(nullable: false), Xp = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_UserXpStats", x => x.Id); }); migrationBuilder.CreateTable( name: "XpSettings", columns: table => new { Id = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true), DateAdded = table.Column(nullable: true), GuildConfigId = table.Column(nullable: false), NotifyMessage = table.Column(nullable: true), ServerExcluded = table.Column(nullable: false), XpRoleRewardExclusive = table.Column(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(nullable: false), UserId = table.Column(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(nullable: false), UserId = table.Column(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(nullable: false) .Annotation("Sqlite:Autoincrement", true), DateAdded = table.Column(nullable: true), ItemId = table.Column(nullable: false), ItemType = table.Column(nullable: false), XpSettingsId = table.Column(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(nullable: false) .Annotation("Sqlite:Autoincrement", true), DateAdded = table.Column(nullable: true), Level = table.Column(nullable: false), RoleId = table.Column(nullable: false), XpSettingsId = table.Column(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"); } } }