1
Fork 0
mirror of https://gitlab.com/Kwoth/nadekobot.git synced 2024-10-02 20:13:13 +00:00

add: Added .cleanupguilddata command which will delete all guildconfigs, xp stats and other data related to any guild the bot is no longer in. This is a highly destructive and irreversible command.

dev: Added cascade deletes to any tables which have guildconfigs FK, as well as to some other missing places
This commit is contained in:
Kwoth 2024-05-18 16:09:54 +00:00
parent 03fb1a5ca2
commit 0c167a9382
28 changed files with 13286 additions and 273 deletions

View file

@ -3,6 +3,8 @@ namespace NadekoBot.Db.Models;
public class DelMsgOnCmdChannel : DbEntity
{
public int GuildConfigId { get; set; }
public ulong ChannelId { get; set; }
public bool State { get; set; }

View file

@ -1,8 +0,0 @@
#nullable disable
namespace NadekoBot.Db.Models;
public class IgnoredVoicePresenceChannel : DbEntity
{
public LogSetting LogSetting { get; set; }
public ulong ChannelId { get; set; }
}

View file

@ -40,6 +40,9 @@ public class StreamRoleSettings : DbEntity
public class StreamRoleBlacklistedUser : DbEntity
{
public int StreamRoleSettingsId { get; set; }
public StreamRoleSettings StreamRoleSettings { get; set; }
public ulong UserId { get; set; }
public string Username { get; set; }
@ -57,6 +60,9 @@ public class StreamRoleBlacklistedUser : DbEntity
public class StreamRoleWhitelistedUser : DbEntity
{
public int StreamRoleSettingsId { get; set; }
public StreamRoleSettings StreamRoleSettings { get; set; }
public ulong UserId { get; set; }
public string Username { get; set; }

View file

@ -2,8 +2,9 @@
public class AntiAltSetting
{
public int Id { get; set; }
public int GuildConfigId { get; set; }
public int Id { get; set; }
public TimeSpan MinAge { get; set; }
public PunishmentAction Action { get; set; }
public int ActionDurationMinutes { get; set; }

View file

@ -1,12 +1,13 @@
#nullable disable
using System.ComponentModel.DataAnnotations.Schema;
namespace NadekoBot.Db.Models;
public class AntiRaidSetting : DbEntity
{
public int GuildConfigId { get; set; }
public GuildConfig GuildConfig { get; set; }
public int UserThreshold { get; set; }
public int Seconds { get; set; }
public PunishmentAction Action { get; set; }

View file

@ -4,8 +4,7 @@
public class AntiSpamSetting : DbEntity
{
public int GuildConfigId { get; set; }
public GuildConfig GuildConfig { get; set; }
public PunishmentAction Action { get; set; }
public int MessageThreshold { get; set; } = 3;
public int MuteTime { get; set; }

View file

@ -14,17 +14,3 @@ public class FilterChannelId : DbEntity
public override int GetHashCode()
=> ChannelId.GetHashCode();
}
public class FilterWordsChannelId : DbEntity
{
public ulong ChannelId { get; set; }
public bool Equals(FilterWordsChannelId other)
=> ChannelId == other.ChannelId;
public override bool Equals(object obj)
=> obj is FilterWordsChannelId fci && Equals(fci);
public override int GetHashCode()
=> ChannelId.GetHashCode();
}

View file

@ -0,0 +1,17 @@
#nullable disable
namespace NadekoBot.Db.Models;
public class FilterWordsChannelId : DbEntity
{
public int? GuildConfigId { get; set; }
public ulong ChannelId { get; set; }
public bool Equals(FilterWordsChannelId other)
=> ChannelId == other.ChannelId;
public override bool Equals(object obj)
=> obj is FilterWordsChannelId fci && Equals(fci);
public override int GetHashCode()
=> ChannelId.GetHashCode();
}

View file

@ -51,6 +51,8 @@ public class XpCurrencyReward : DbEntity
public class ExcludedItem : DbEntity
{
public XpSettings XpSettings { get; set; }
public ulong ItemId { get; set; }
public ExcludedItemType ItemType { get; set; }

View file

@ -28,7 +28,6 @@ public abstract class NadekoContext : DbContext
//logging
public DbSet<LogSetting> LogSettings { get; set; }
public DbSet<IgnoredVoicePresenceChannel> IgnoredVoicePresenceCHannels { get; set; }
public DbSet<IgnoredLogItem> IgnoredLogChannels { get; set; }
public DbSet<RotatingPlayingStatus> RotatingStatus { get; set; }
@ -55,14 +54,14 @@ public abstract class NadekoContext : DbContext
public DbSet<PatronUser> Patrons { get; set; }
public DbSet<PatronQuota> PatronQuotas { get; set; }
public DbSet<StreamOnlineMessage> StreamOnlineMessages { get; set; }
public DbSet<StickyRole> StickyRoles { get; set; }
public DbSet<TodoModel> Todos { get; set; }
public DbSet<ArchivedTodoListModel> TodosArchive { get; set; }
// todo add guild colors
// public DbSet<GuildColors> GuildColors { get; set; }
@ -86,15 +85,84 @@ public abstract class NadekoContext : DbContext
#region GuildConfig
var configEntity = modelBuilder.Entity<GuildConfig>();
configEntity.HasIndex(c => c.GuildId)
.IsUnique();
configEntity.Property(x => x.VerboseErrors)
.HasDefaultValue(true);
modelBuilder.Entity<AntiSpamSetting>().HasOne(x => x.GuildConfig).WithOne(x => x.AntiSpamSetting);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.DelMsgOnCmdChannels)
.WithOne()
.HasForeignKey(x => x.GuildConfigId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<AntiRaidSetting>().HasOne(x => x.GuildConfig).WithOne(x => x.AntiRaidSetting);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.FollowedStreams)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.GenerateCurrencyChannelIds)
.WithOne(x => x.GuildConfig)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.Permissions)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.CommandCooldowns)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.FilterInvitesChannelIds)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.FilterLinksChannelIds)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.FilteredWords)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.FilterWordsChannelIds)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.MutedUsers)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasOne(x => x.AntiRaidSetting)
.WithOne()
.HasForeignKey<AntiRaidSetting>(x => x.GuildConfigId)
.OnDelete(DeleteBehavior.Cascade);
// start antispam
modelBuilder.Entity<GuildConfig>()
.HasOne(x => x.AntiSpamSetting)
.WithOne()
.HasForeignKey<AntiSpamSetting>(x => x.GuildConfigId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<AntiSpamSetting>()
.HasMany(x => x.IgnoredChannels)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
// end antispam
modelBuilder.Entity<GuildConfig>()
.HasOne(x => x.AntiAltSetting)
@ -102,6 +170,98 @@ public abstract class NadekoContext : DbContext
.HasForeignKey<AntiAltSetting>(x => x.GuildConfigId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.UnmuteTimers)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.UnbanTimer)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.UnroleTimer)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.VcRoleInfos)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.CommandAliases)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.WarnPunishments)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.SlowmodeIgnoredRoles)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.SlowmodeIgnoredUsers)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
// start shop
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.ShopEntries)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<ShopEntry>()
.HasMany(x => x.Items)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
// end shop
// start streamrole
modelBuilder.Entity<GuildConfig>()
.HasOne(x => x.StreamRole)
.WithOne(x => x.GuildConfig)
.HasForeignKey<StreamRoleSettings>(x => x.GuildConfigId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<StreamRoleSettings>()
.HasMany(x => x.Whitelist)
.WithOne(x => x.StreamRoleSettings)
.HasForeignKey(x => x.StreamRoleSettingsId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<StreamRoleSettings>()
.HasMany(x => x.Blacklist)
.WithOne(x => x.StreamRoleSettings)
.HasForeignKey(x => x.StreamRoleSettingsId)
.OnDelete(DeleteBehavior.Cascade);
// end streamrole
modelBuilder.Entity<GuildConfig>()
.HasOne(x => x.XpSettings)
.WithOne(x => x.GuildConfig)
.HasForeignKey<XpSettings>(x => x.GuildConfigId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.FeedSubs)
.WithOne(x => x.GuildConfig)
.HasForeignKey(x => x.GuildConfigId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.SelfAssignableRoleGroupNames)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<FeedSub>()
.HasAlternateKey(x => new
{
@ -117,11 +277,6 @@ public abstract class NadekoContext : DbContext
#endregion
#region streamrole
modelBuilder.Entity<StreamRoleSettings>().HasOne(x => x.GuildConfig).WithOne(x => x.StreamRole);
#endregion
#region Self Assignable Roles
@ -217,12 +372,6 @@ public abstract class NadekoContext : DbContext
#endregion
#region XpSettings
modelBuilder.Entity<XpSettings>().HasOne(x => x.GuildConfig).WithOne(x => x.XpSettings);
#endregion
#region XpRoleReward
modelBuilder.Entity<XpRoleReward>()
@ -233,6 +382,21 @@ public abstract class NadekoContext : DbContext
})
.IsUnique();
modelBuilder.Entity<XpSettings>()
.HasMany(x => x.RoleRewards)
.WithOne(x => x.XpSettings)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<XpSettings>()
.HasMany(x => x.CurrencyRewards)
.WithOne(x => x.XpSettings)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<XpSettings>()
.HasMany(x => x.ExclusionList)
.WithOne(x => x.XpSettings)
.OnDelete(DeleteBehavior.Cascade);
#endregion
#region Club
@ -331,9 +495,9 @@ public abstract class NadekoContext : DbContext
modelBuilder.Entity<BanTemplate>().HasIndex(x => x.GuildId).IsUnique();
modelBuilder.Entity<BanTemplate>()
.Property(x => x.PruneDays)
.HasDefaultValue(null)
.IsRequired(false);
.Property(x => x.PruneDays)
.HasDefaultValue(null)
.IsRequired(false);
#endregion
@ -445,7 +609,7 @@ public abstract class NadekoContext : DbContext
});
#endregion
#region Xp Item Shop
modelBuilder.Entity<XpShopOwnedItem>(
@ -453,76 +617,77 @@ public abstract class NadekoContext : DbContext
{
// user can own only one of each item
x.HasIndex(model => new
{
model.UserId,
model.ItemType,
model.ItemKey
})
.IsUnique();
{
model.UserId,
model.ItemType,
model.ItemKey
})
.IsUnique();
});
#endregion
#region AutoPublish
modelBuilder.Entity<AutoPublishChannel>(apc => apc
.HasIndex(x => x.GuildId)
.IsUnique());
.HasIndex(x => x.GuildId)
.IsUnique());
#endregion
#region GamblingStats
modelBuilder.Entity<GamblingStats>(gs => gs
.HasIndex(x => x.Feature)
.IsUnique());
.HasIndex(x => x.Feature)
.IsUnique());
#endregion
#region Sticky Roles
modelBuilder.Entity<StickyRole>(sr => sr.HasIndex(x => new
{
x.GuildId,
x.UserId
}).IsUnique());
{
x.GuildId,
x.UserId
})
.IsUnique());
#endregion
#region Giveaway
modelBuilder.Entity<GiveawayModel>()
.HasMany(x => x.Participants)
.WithOne()
.HasForeignKey(x => x.GiveawayId)
.OnDelete(DeleteBehavior.Cascade);
.HasMany(x => x.Participants)
.WithOne()
.HasForeignKey(x => x.GiveawayId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GiveawayUser>(gu => gu
.HasIndex(x => new
{
x.GiveawayId,
x.UserId
})
.IsUnique());
.HasIndex(x => new
{
x.GiveawayId,
x.UserId
})
.IsUnique());
#endregion
#region Todo
modelBuilder.Entity<TodoModel>()
.HasKey(x => x.Id);
modelBuilder.Entity<TodoModel>()
.HasIndex(x => x.UserId)
.IsUnique(false);
.HasIndex(x => x.UserId)
.IsUnique(false);
modelBuilder.Entity<ArchivedTodoListModel>()
.HasMany(x => x.Items)
.WithOne()
.HasForeignKey(x => x.ArchiveId)
.OnDelete(DeleteBehavior.Cascade);
.HasMany(x => x.Items)
.WithOne()
.HasForeignKey(x => x.ArchiveId)
.OnDelete(DeleteBehavior.Cascade);
#endregion
}

View file

@ -1,5 +1,6 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Migrations;
using NadekoBot.Db.Models;
namespace NadekoBot.Migrations;
@ -39,4 +40,15 @@ left join guildconfigs on reactionrolemessage.guildconfigid = guildconfigs.id;")
throw new NotSupportedException("This database provider doesn't have an implementation for MigrateRero");
}
}
public static void GuildConfigCleanup(MigrationBuilder builder)
{
builder.Sql($"""
DELETE FROM "StreamRoleBlacklistedUser" WHERE "StreamRoleSettingsId" is NULL;
""");
builder.Sql($"""
DELETE FROM "DelMsgOnCmdChannel" WHERE "GuildConfigId" is NULL;
""");
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,703 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace NadekoBot.Migrations.Mysql
{
/// <inheritdoc />
public partial class guidlconfigcleanup : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "fk_antiraidsetting_guildconfigs_guildconfigid",
table: "antiraidsetting");
migrationBuilder.DropForeignKey(
name: "fk_antispamignore_antispamsetting_antispamsettingid",
table: "antispamignore");
migrationBuilder.DropForeignKey(
name: "fk_antispamsetting_guildconfigs_guildconfigid",
table: "antispamsetting");
migrationBuilder.DropForeignKey(
name: "fk_commandalias_guildconfigs_guildconfigid",
table: "commandalias");
migrationBuilder.DropForeignKey(
name: "fk_commandcooldown_guildconfigs_guildconfigid",
table: "commandcooldown");
migrationBuilder.DropForeignKey(
name: "fk_delmsgoncmdchannel_guildconfigs_guildconfigid",
table: "delmsgoncmdchannel");
migrationBuilder.DropForeignKey(
name: "fk_excludeditem_xpsettings_xpsettingsid",
table: "excludeditem");
migrationBuilder.DropForeignKey(
name: "fk_filterchannelid_guildconfigs_guildconfigid",
table: "filterchannelid");
migrationBuilder.DropForeignKey(
name: "fk_filteredword_guildconfigs_guildconfigid",
table: "filteredword");
migrationBuilder.DropForeignKey(
name: "fk_filterlinkschannelid_guildconfigs_guildconfigid",
table: "filterlinkschannelid");
migrationBuilder.DropForeignKey(
name: "fk_filterwordschannelid_guildconfigs_guildconfigid",
table: "filterwordschannelid");
migrationBuilder.DropForeignKey(
name: "fk_followedstream_guildconfigs_guildconfigid",
table: "followedstream");
migrationBuilder.DropForeignKey(
name: "fk_gcchannelid_guildconfigs_guildconfigid",
table: "gcchannelid");
migrationBuilder.DropForeignKey(
name: "fk_muteduserid_guildconfigs_guildconfigid",
table: "muteduserid");
migrationBuilder.DropForeignKey(
name: "fk_permissions_guildconfigs_guildconfigid",
table: "permissions");
migrationBuilder.DropForeignKey(
name: "fk_shopentry_guildconfigs_guildconfigid",
table: "shopentry");
migrationBuilder.DropForeignKey(
name: "fk_shopentryitem_shopentry_shopentryid",
table: "shopentryitem");
migrationBuilder.DropForeignKey(
name: "fk_slowmodeignoredrole_guildconfigs_guildconfigid",
table: "slowmodeignoredrole");
migrationBuilder.DropForeignKey(
name: "fk_slowmodeignoreduser_guildconfigs_guildconfigid",
table: "slowmodeignoreduser");
migrationBuilder.DropForeignKey(
name: "fk_streamroleblacklisteduser_streamrolesettings_streamrolesetti~",
table: "streamroleblacklisteduser");
migrationBuilder.DropForeignKey(
name: "fk_streamrolewhitelisteduser_streamrolesettings_streamrolesetti~",
table: "streamrolewhitelisteduser");
migrationBuilder.DropForeignKey(
name: "fk_unbantimer_guildconfigs_guildconfigid",
table: "unbantimer");
migrationBuilder.DropForeignKey(
name: "fk_unmutetimer_guildconfigs_guildconfigid",
table: "unmutetimer");
migrationBuilder.DropForeignKey(
name: "fk_unroletimer_guildconfigs_guildconfigid",
table: "unroletimer");
migrationBuilder.DropForeignKey(
name: "fk_vcroleinfo_guildconfigs_guildconfigid",
table: "vcroleinfo");
migrationBuilder.DropForeignKey(
name: "fk_warningpunishment_guildconfigs_guildconfigid",
table: "warningpunishment");
migrationBuilder.DropTable(
name: "ignoredvoicepresencechannels");
migrationBuilder.AlterColumn<int>(
name: "streamrolesettingsid",
table: "streamrolewhitelisteduser",
type: "int",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "streamrolesettingsid",
table: "streamroleblacklisteduser",
type: "int",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "guildconfigid",
table: "delmsgoncmdchannel",
type: "int",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "fk_antiraidsetting_guildconfigs_guildconfigid",
table: "antiraidsetting",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_antispamignore_antispamsetting_antispamsettingid",
table: "antispamignore",
column: "antispamsettingid",
principalTable: "antispamsetting",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_antispamsetting_guildconfigs_guildconfigid",
table: "antispamsetting",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_commandalias_guildconfigs_guildconfigid",
table: "commandalias",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_commandcooldown_guildconfigs_guildconfigid",
table: "commandcooldown",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_delmsgoncmdchannel_guildconfigs_guildconfigid",
table: "delmsgoncmdchannel",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_excludeditem_xpsettings_xpsettingsid",
table: "excludeditem",
column: "xpsettingsid",
principalTable: "xpsettings",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_filterchannelid_guildconfigs_guildconfigid",
table: "filterchannelid",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_filteredword_guildconfigs_guildconfigid",
table: "filteredword",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_filterlinkschannelid_guildconfigs_guildconfigid",
table: "filterlinkschannelid",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_filterwordschannelid_guildconfigs_guildconfigid",
table: "filterwordschannelid",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_followedstream_guildconfigs_guildconfigid",
table: "followedstream",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_gcchannelid_guildconfigs_guildconfigid",
table: "gcchannelid",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_muteduserid_guildconfigs_guildconfigid",
table: "muteduserid",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_permissions_guildconfigs_guildconfigid",
table: "permissions",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_shopentry_guildconfigs_guildconfigid",
table: "shopentry",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_shopentryitem_shopentry_shopentryid",
table: "shopentryitem",
column: "shopentryid",
principalTable: "shopentry",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_slowmodeignoredrole_guildconfigs_guildconfigid",
table: "slowmodeignoredrole",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_slowmodeignoreduser_guildconfigs_guildconfigid",
table: "slowmodeignoreduser",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_streamroleblacklisteduser_streamrolesettings_streamrolesetti~",
table: "streamroleblacklisteduser",
column: "streamrolesettingsid",
principalTable: "streamrolesettings",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_streamrolewhitelisteduser_streamrolesettings_streamrolesetti~",
table: "streamrolewhitelisteduser",
column: "streamrolesettingsid",
principalTable: "streamrolesettings",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_unbantimer_guildconfigs_guildconfigid",
table: "unbantimer",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_unmutetimer_guildconfigs_guildconfigid",
table: "unmutetimer",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_unroletimer_guildconfigs_guildconfigid",
table: "unroletimer",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_vcroleinfo_guildconfigs_guildconfigid",
table: "vcroleinfo",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_warningpunishment_guildconfigs_guildconfigid",
table: "warningpunishment",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "fk_antiraidsetting_guildconfigs_guildconfigid",
table: "antiraidsetting");
migrationBuilder.DropForeignKey(
name: "fk_antispamignore_antispamsetting_antispamsettingid",
table: "antispamignore");
migrationBuilder.DropForeignKey(
name: "fk_antispamsetting_guildconfigs_guildconfigid",
table: "antispamsetting");
migrationBuilder.DropForeignKey(
name: "fk_commandalias_guildconfigs_guildconfigid",
table: "commandalias");
migrationBuilder.DropForeignKey(
name: "fk_commandcooldown_guildconfigs_guildconfigid",
table: "commandcooldown");
migrationBuilder.DropForeignKey(
name: "fk_delmsgoncmdchannel_guildconfigs_guildconfigid",
table: "delmsgoncmdchannel");
migrationBuilder.DropForeignKey(
name: "fk_excludeditem_xpsettings_xpsettingsid",
table: "excludeditem");
migrationBuilder.DropForeignKey(
name: "fk_filterchannelid_guildconfigs_guildconfigid",
table: "filterchannelid");
migrationBuilder.DropForeignKey(
name: "fk_filteredword_guildconfigs_guildconfigid",
table: "filteredword");
migrationBuilder.DropForeignKey(
name: "fk_filterlinkschannelid_guildconfigs_guildconfigid",
table: "filterlinkschannelid");
migrationBuilder.DropForeignKey(
name: "fk_filterwordschannelid_guildconfigs_guildconfigid",
table: "filterwordschannelid");
migrationBuilder.DropForeignKey(
name: "fk_followedstream_guildconfigs_guildconfigid",
table: "followedstream");
migrationBuilder.DropForeignKey(
name: "fk_gcchannelid_guildconfigs_guildconfigid",
table: "gcchannelid");
migrationBuilder.DropForeignKey(
name: "fk_muteduserid_guildconfigs_guildconfigid",
table: "muteduserid");
migrationBuilder.DropForeignKey(
name: "fk_permissions_guildconfigs_guildconfigid",
table: "permissions");
migrationBuilder.DropForeignKey(
name: "fk_shopentry_guildconfigs_guildconfigid",
table: "shopentry");
migrationBuilder.DropForeignKey(
name: "fk_shopentryitem_shopentry_shopentryid",
table: "shopentryitem");
migrationBuilder.DropForeignKey(
name: "fk_slowmodeignoredrole_guildconfigs_guildconfigid",
table: "slowmodeignoredrole");
migrationBuilder.DropForeignKey(
name: "fk_slowmodeignoreduser_guildconfigs_guildconfigid",
table: "slowmodeignoreduser");
migrationBuilder.DropForeignKey(
name: "fk_streamroleblacklisteduser_streamrolesettings_streamrolesetti~",
table: "streamroleblacklisteduser");
migrationBuilder.DropForeignKey(
name: "fk_streamrolewhitelisteduser_streamrolesettings_streamrolesetti~",
table: "streamrolewhitelisteduser");
migrationBuilder.DropForeignKey(
name: "fk_unbantimer_guildconfigs_guildconfigid",
table: "unbantimer");
migrationBuilder.DropForeignKey(
name: "fk_unmutetimer_guildconfigs_guildconfigid",
table: "unmutetimer");
migrationBuilder.DropForeignKey(
name: "fk_unroletimer_guildconfigs_guildconfigid",
table: "unroletimer");
migrationBuilder.DropForeignKey(
name: "fk_vcroleinfo_guildconfigs_guildconfigid",
table: "vcroleinfo");
migrationBuilder.DropForeignKey(
name: "fk_warningpunishment_guildconfigs_guildconfigid",
table: "warningpunishment");
migrationBuilder.AlterColumn<int>(
name: "streamrolesettingsid",
table: "streamrolewhitelisteduser",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.AlterColumn<int>(
name: "streamrolesettingsid",
table: "streamroleblacklisteduser",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.AlterColumn<int>(
name: "guildconfigid",
table: "delmsgoncmdchannel",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.CreateTable(
name: "ignoredvoicepresencechannels",
columns: table => new
{
id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
logsettingid = table.Column<int>(type: "int", nullable: true),
channelid = table.Column<ulong>(type: "bigint unsigned", nullable: false),
dateadded = table.Column<DateTime>(type: "datetime(6)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_ignoredvoicepresencechannels", x => x.id);
table.ForeignKey(
name: "fk_ignoredvoicepresencechannels_logsettings_logsettingid",
column: x => x.logsettingid,
principalTable: "logsettings",
principalColumn: "id");
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "ix_ignoredvoicepresencechannels_logsettingid",
table: "ignoredvoicepresencechannels",
column: "logsettingid");
migrationBuilder.AddForeignKey(
name: "fk_antiraidsetting_guildconfigs_guildconfigid",
table: "antiraidsetting",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_antispamignore_antispamsetting_antispamsettingid",
table: "antispamignore",
column: "antispamsettingid",
principalTable: "antispamsetting",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_antispamsetting_guildconfigs_guildconfigid",
table: "antispamsetting",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_commandalias_guildconfigs_guildconfigid",
table: "commandalias",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_commandcooldown_guildconfigs_guildconfigid",
table: "commandcooldown",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_delmsgoncmdchannel_guildconfigs_guildconfigid",
table: "delmsgoncmdchannel",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_excludeditem_xpsettings_xpsettingsid",
table: "excludeditem",
column: "xpsettingsid",
principalTable: "xpsettings",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_filterchannelid_guildconfigs_guildconfigid",
table: "filterchannelid",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_filteredword_guildconfigs_guildconfigid",
table: "filteredword",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_filterlinkschannelid_guildconfigs_guildconfigid",
table: "filterlinkschannelid",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_filterwordschannelid_guildconfigs_guildconfigid",
table: "filterwordschannelid",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_followedstream_guildconfigs_guildconfigid",
table: "followedstream",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_gcchannelid_guildconfigs_guildconfigid",
table: "gcchannelid",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_muteduserid_guildconfigs_guildconfigid",
table: "muteduserid",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_permissions_guildconfigs_guildconfigid",
table: "permissions",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_shopentry_guildconfigs_guildconfigid",
table: "shopentry",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_shopentryitem_shopentry_shopentryid",
table: "shopentryitem",
column: "shopentryid",
principalTable: "shopentry",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_slowmodeignoredrole_guildconfigs_guildconfigid",
table: "slowmodeignoredrole",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_slowmodeignoreduser_guildconfigs_guildconfigid",
table: "slowmodeignoreduser",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_streamroleblacklisteduser_streamrolesettings_streamrolesetti~",
table: "streamroleblacklisteduser",
column: "streamrolesettingsid",
principalTable: "streamrolesettings",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_streamrolewhitelisteduser_streamrolesettings_streamrolesetti~",
table: "streamrolewhitelisteduser",
column: "streamrolesettingsid",
principalTable: "streamrolesettings",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_unbantimer_guildconfigs_guildconfigid",
table: "unbantimer",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_unmutetimer_guildconfigs_guildconfigid",
table: "unmutetimer",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_unroletimer_guildconfigs_guildconfigid",
table: "unroletimer",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_vcroleinfo_guildconfigs_guildconfigid",
table: "vcroleinfo",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_warningpunishment_guildconfigs_guildconfigid",
table: "warningpunishment",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
}
}
}

View file

@ -673,7 +673,7 @@ namespace NadekoBot.Migrations.Mysql
.HasColumnType("datetime(6)")
.HasColumnName("dateadded");
b.Property<int?>("GuildConfigId")
b.Property<int>("GuildConfigId")
.HasColumnType("int")
.HasColumnName("guildconfigid");
@ -1423,36 +1423,6 @@ namespace NadekoBot.Migrations.Mysql
b.ToTable("ignoredlogchannels", (string)null);
});
modelBuilder.Entity("NadekoBot.Db.Models.IgnoredVoicePresenceChannel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasColumnName("id");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<ulong>("ChannelId")
.HasColumnType("bigint unsigned")
.HasColumnName("channelid");
b.Property<DateTime?>("DateAdded")
.HasColumnType("datetime(6)")
.HasColumnName("dateadded");
b.Property<int?>("LogSettingId")
.HasColumnType("int")
.HasColumnName("logsettingid");
b.HasKey("Id")
.HasName("pk_ignoredvoicepresencechannels");
b.HasIndex("LogSettingId")
.HasDatabaseName("ix_ignoredvoicepresencechannels_logsettingid");
b.ToTable("ignoredvoicepresencechannels", (string)null);
});
modelBuilder.Entity("NadekoBot.Db.Models.ImageOnlyChannel", b =>
{
b.Property<int>("Id")
@ -2510,7 +2480,7 @@ namespace NadekoBot.Migrations.Mysql
.HasColumnType("datetime(6)")
.HasColumnName("dateadded");
b.Property<int?>("StreamRoleSettingsId")
b.Property<int>("StreamRoleSettingsId")
.HasColumnType("int")
.HasColumnName("streamrolesettingsid");
@ -2587,7 +2557,7 @@ namespace NadekoBot.Migrations.Mysql
.HasColumnType("datetime(6)")
.HasColumnName("dateadded");
b.Property<int?>("StreamRoleSettingsId")
b.Property<int>("StreamRoleSettingsId")
.HasColumnType("int")
.HasColumnName("streamrolesettingsid");
@ -3226,14 +3196,12 @@ namespace NadekoBot.Migrations.Mysql
modelBuilder.Entity("NadekoBot.Db.Models.AntiRaidSetting", b =>
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", "GuildConfig")
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithOne("AntiRaidSetting")
.HasForeignKey("NadekoBot.Db.Models.AntiRaidSetting", "GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_antiraidsetting_guildconfigs_guildconfigid");
b.Navigation("GuildConfig");
});
modelBuilder.Entity("NadekoBot.Db.Models.AntiSpamIgnore", b =>
@ -3241,19 +3209,18 @@ namespace NadekoBot.Migrations.Mysql
b.HasOne("NadekoBot.Db.Models.AntiSpamSetting", null)
.WithMany("IgnoredChannels")
.HasForeignKey("AntiSpamSettingId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_antispamignore_antispamsetting_antispamsettingid");
});
modelBuilder.Entity("NadekoBot.Db.Models.AntiSpamSetting", b =>
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", "GuildConfig")
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithOne("AntiSpamSetting")
.HasForeignKey("NadekoBot.Db.Models.AntiSpamSetting", "GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_antispamsetting_guildconfigs_guildconfigid");
b.Navigation("GuildConfig");
});
modelBuilder.Entity("NadekoBot.Db.Models.AutoTranslateUser", b =>
@ -3326,6 +3293,7 @@ namespace NadekoBot.Migrations.Mysql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("CommandAliases")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_commandalias_guildconfigs_guildconfigid");
});
@ -3334,6 +3302,7 @@ namespace NadekoBot.Migrations.Mysql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("CommandCooldowns")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_commandcooldown_guildconfigs_guildconfigid");
});
@ -3342,6 +3311,8 @@ namespace NadekoBot.Migrations.Mysql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("DelMsgOnCmdChannels")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_delmsgoncmdchannel_guildconfigs_guildconfigid");
});
@ -3358,10 +3329,13 @@ namespace NadekoBot.Migrations.Mysql
modelBuilder.Entity("NadekoBot.Db.Models.ExcludedItem", b =>
{
b.HasOne("NadekoBot.Db.Models.XpSettings", null)
b.HasOne("NadekoBot.Db.Models.XpSettings", "XpSettings")
.WithMany("ExclusionList")
.HasForeignKey("XpSettingsId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_excludeditem_xpsettings_xpsettingsid");
b.Navigation("XpSettings");
});
modelBuilder.Entity("NadekoBot.Db.Models.FeedSub", b =>
@ -3381,6 +3355,7 @@ namespace NadekoBot.Migrations.Mysql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("FilterInvitesChannelIds")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_filterchannelid_guildconfigs_guildconfigid");
});
@ -3389,6 +3364,7 @@ namespace NadekoBot.Migrations.Mysql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("FilterLinksChannelIds")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_filterlinkschannelid_guildconfigs_guildconfigid");
});
@ -3397,6 +3373,7 @@ namespace NadekoBot.Migrations.Mysql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("FilterWordsChannelIds")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_filterwordschannelid_guildconfigs_guildconfigid");
});
@ -3405,6 +3382,7 @@ namespace NadekoBot.Migrations.Mysql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("FilteredWords")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_filteredword_guildconfigs_guildconfigid");
});
@ -3413,6 +3391,7 @@ namespace NadekoBot.Migrations.Mysql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("FollowedStreams")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_followedstream_guildconfigs_guildconfigid");
});
@ -3421,6 +3400,7 @@ namespace NadekoBot.Migrations.Mysql
b.HasOne("NadekoBot.Db.Models.GuildConfig", "GuildConfig")
.WithMany("GenerateCurrencyChannelIds")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_gcchannelid_guildconfigs_guildconfigid");
b.Navigation("GuildConfig");
@ -3460,21 +3440,12 @@ namespace NadekoBot.Migrations.Mysql
b.Navigation("LogSetting");
});
modelBuilder.Entity("NadekoBot.Db.Models.IgnoredVoicePresenceChannel", b =>
{
b.HasOne("NadekoBot.Db.Models.LogSetting", "LogSetting")
.WithMany()
.HasForeignKey("LogSettingId")
.HasConstraintName("fk_ignoredvoicepresencechannels_logsettings_logsettingid");
b.Navigation("LogSetting");
});
modelBuilder.Entity("NadekoBot.Db.Models.MutedUserId", b =>
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("MutedUsers")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_muteduserid_guildconfigs_guildconfigid");
});
@ -3483,6 +3454,7 @@ namespace NadekoBot.Migrations.Mysql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("Permissions")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_permissions_guildconfigs_guildconfigid");
});
@ -3500,6 +3472,7 @@ namespace NadekoBot.Migrations.Mysql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("ShopEntries")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_shopentry_guildconfigs_guildconfigid");
});
@ -3508,6 +3481,7 @@ namespace NadekoBot.Migrations.Mysql
b.HasOne("NadekoBot.Db.Models.ShopEntry", null)
.WithMany("Items")
.HasForeignKey("ShopEntryId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_shopentryitem_shopentry_shopentryid");
});
@ -3516,6 +3490,7 @@ namespace NadekoBot.Migrations.Mysql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("SlowmodeIgnoredRoles")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_slowmodeignoredrole_guildconfigs_guildconfigid");
});
@ -3524,15 +3499,20 @@ namespace NadekoBot.Migrations.Mysql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("SlowmodeIgnoredUsers")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_slowmodeignoreduser_guildconfigs_guildconfigid");
});
modelBuilder.Entity("NadekoBot.Db.Models.StreamRoleBlacklistedUser", b =>
{
b.HasOne("NadekoBot.Db.Models.StreamRoleSettings", null)
b.HasOne("NadekoBot.Db.Models.StreamRoleSettings", "StreamRoleSettings")
.WithMany("Blacklist")
.HasForeignKey("StreamRoleSettingsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_streamroleblacklisteduser_streamrolesettings_streamrolesetti~");
b.Navigation("StreamRoleSettings");
});
modelBuilder.Entity("NadekoBot.Db.Models.StreamRoleSettings", b =>
@ -3549,10 +3529,14 @@ namespace NadekoBot.Migrations.Mysql
modelBuilder.Entity("NadekoBot.Db.Models.StreamRoleWhitelistedUser", b =>
{
b.HasOne("NadekoBot.Db.Models.StreamRoleSettings", null)
b.HasOne("NadekoBot.Db.Models.StreamRoleSettings", "StreamRoleSettings")
.WithMany("Whitelist")
.HasForeignKey("StreamRoleSettingsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_streamrolewhitelisteduser_streamrolesettings_streamrolesetti~");
b.Navigation("StreamRoleSettings");
});
modelBuilder.Entity("NadekoBot.Db.Models.TodoModel", b =>
@ -3569,6 +3553,7 @@ namespace NadekoBot.Migrations.Mysql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("UnbanTimer")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_unbantimer_guildconfigs_guildconfigid");
});
@ -3577,6 +3562,7 @@ namespace NadekoBot.Migrations.Mysql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("UnmuteTimers")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_unmutetimer_guildconfigs_guildconfigid");
});
@ -3585,6 +3571,7 @@ namespace NadekoBot.Migrations.Mysql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("UnroleTimer")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_unroletimer_guildconfigs_guildconfigid");
});
@ -3593,6 +3580,7 @@ namespace NadekoBot.Migrations.Mysql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("VcRoleInfos")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_vcroleinfo_guildconfigs_guildconfigid");
});
@ -3663,6 +3651,7 @@ namespace NadekoBot.Migrations.Mysql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("WarnPunishments")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_warningpunishment_guildconfigs_guildconfigid");
});

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,702 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace NadekoBot.Migrations.PostgreSql
{
/// <inheritdoc />
public partial class guidlconfigcleanup : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "fk_antiraidsetting_guildconfigs_guildconfigid",
table: "antiraidsetting");
migrationBuilder.DropForeignKey(
name: "fk_antispamignore_antispamsetting_antispamsettingid",
table: "antispamignore");
migrationBuilder.DropForeignKey(
name: "fk_antispamsetting_guildconfigs_guildconfigid",
table: "antispamsetting");
migrationBuilder.DropForeignKey(
name: "fk_commandalias_guildconfigs_guildconfigid",
table: "commandalias");
migrationBuilder.DropForeignKey(
name: "fk_commandcooldown_guildconfigs_guildconfigid",
table: "commandcooldown");
migrationBuilder.DropForeignKey(
name: "fk_delmsgoncmdchannel_guildconfigs_guildconfigid",
table: "delmsgoncmdchannel");
migrationBuilder.DropForeignKey(
name: "fk_excludeditem_xpsettings_xpsettingsid",
table: "excludeditem");
migrationBuilder.DropForeignKey(
name: "fk_filterchannelid_guildconfigs_guildconfigid",
table: "filterchannelid");
migrationBuilder.DropForeignKey(
name: "fk_filteredword_guildconfigs_guildconfigid",
table: "filteredword");
migrationBuilder.DropForeignKey(
name: "fk_filterlinkschannelid_guildconfigs_guildconfigid",
table: "filterlinkschannelid");
migrationBuilder.DropForeignKey(
name: "fk_filterwordschannelid_guildconfigs_guildconfigid",
table: "filterwordschannelid");
migrationBuilder.DropForeignKey(
name: "fk_followedstream_guildconfigs_guildconfigid",
table: "followedstream");
migrationBuilder.DropForeignKey(
name: "fk_gcchannelid_guildconfigs_guildconfigid",
table: "gcchannelid");
migrationBuilder.DropForeignKey(
name: "fk_muteduserid_guildconfigs_guildconfigid",
table: "muteduserid");
migrationBuilder.DropForeignKey(
name: "fk_permissions_guildconfigs_guildconfigid",
table: "permissions");
migrationBuilder.DropForeignKey(
name: "fk_shopentry_guildconfigs_guildconfigid",
table: "shopentry");
migrationBuilder.DropForeignKey(
name: "fk_shopentryitem_shopentry_shopentryid",
table: "shopentryitem");
migrationBuilder.DropForeignKey(
name: "fk_slowmodeignoredrole_guildconfigs_guildconfigid",
table: "slowmodeignoredrole");
migrationBuilder.DropForeignKey(
name: "fk_slowmodeignoreduser_guildconfigs_guildconfigid",
table: "slowmodeignoreduser");
migrationBuilder.DropForeignKey(
name: "fk_streamroleblacklisteduser_streamrolesettings_streamrolesett~",
table: "streamroleblacklisteduser");
migrationBuilder.DropForeignKey(
name: "fk_streamrolewhitelisteduser_streamrolesettings_streamrolesett~",
table: "streamrolewhitelisteduser");
migrationBuilder.DropForeignKey(
name: "fk_unbantimer_guildconfigs_guildconfigid",
table: "unbantimer");
migrationBuilder.DropForeignKey(
name: "fk_unmutetimer_guildconfigs_guildconfigid",
table: "unmutetimer");
migrationBuilder.DropForeignKey(
name: "fk_unroletimer_guildconfigs_guildconfigid",
table: "unroletimer");
migrationBuilder.DropForeignKey(
name: "fk_vcroleinfo_guildconfigs_guildconfigid",
table: "vcroleinfo");
migrationBuilder.DropForeignKey(
name: "fk_warningpunishment_guildconfigs_guildconfigid",
table: "warningpunishment");
migrationBuilder.DropTable(
name: "ignoredvoicepresencechannels");
migrationBuilder.AlterColumn<int>(
name: "streamrolesettingsid",
table: "streamrolewhitelisteduser",
type: "integer",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "integer",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "streamrolesettingsid",
table: "streamroleblacklisteduser",
type: "integer",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "integer",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "guildconfigid",
table: "delmsgoncmdchannel",
type: "integer",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "integer",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "fk_antiraidsetting_guildconfigs_guildconfigid",
table: "antiraidsetting",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_antispamignore_antispamsetting_antispamsettingid",
table: "antispamignore",
column: "antispamsettingid",
principalTable: "antispamsetting",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_antispamsetting_guildconfigs_guildconfigid",
table: "antispamsetting",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_commandalias_guildconfigs_guildconfigid",
table: "commandalias",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_commandcooldown_guildconfigs_guildconfigid",
table: "commandcooldown",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_delmsgoncmdchannel_guildconfigs_guildconfigid",
table: "delmsgoncmdchannel",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_excludeditem_xpsettings_xpsettingsid",
table: "excludeditem",
column: "xpsettingsid",
principalTable: "xpsettings",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_filterchannelid_guildconfigs_guildconfigid",
table: "filterchannelid",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_filteredword_guildconfigs_guildconfigid",
table: "filteredword",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_filterlinkschannelid_guildconfigs_guildconfigid",
table: "filterlinkschannelid",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_filterwordschannelid_guildconfigs_guildconfigid",
table: "filterwordschannelid",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_followedstream_guildconfigs_guildconfigid",
table: "followedstream",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_gcchannelid_guildconfigs_guildconfigid",
table: "gcchannelid",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_muteduserid_guildconfigs_guildconfigid",
table: "muteduserid",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_permissions_guildconfigs_guildconfigid",
table: "permissions",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_shopentry_guildconfigs_guildconfigid",
table: "shopentry",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_shopentryitem_shopentry_shopentryid",
table: "shopentryitem",
column: "shopentryid",
principalTable: "shopentry",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_slowmodeignoredrole_guildconfigs_guildconfigid",
table: "slowmodeignoredrole",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_slowmodeignoreduser_guildconfigs_guildconfigid",
table: "slowmodeignoreduser",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_streamroleblacklisteduser_streamrolesettings_streamrolesett~",
table: "streamroleblacklisteduser",
column: "streamrolesettingsid",
principalTable: "streamrolesettings",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_streamrolewhitelisteduser_streamrolesettings_streamrolesett~",
table: "streamrolewhitelisteduser",
column: "streamrolesettingsid",
principalTable: "streamrolesettings",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_unbantimer_guildconfigs_guildconfigid",
table: "unbantimer",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_unmutetimer_guildconfigs_guildconfigid",
table: "unmutetimer",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_unroletimer_guildconfigs_guildconfigid",
table: "unroletimer",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_vcroleinfo_guildconfigs_guildconfigid",
table: "vcroleinfo",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_warningpunishment_guildconfigs_guildconfigid",
table: "warningpunishment",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "fk_antiraidsetting_guildconfigs_guildconfigid",
table: "antiraidsetting");
migrationBuilder.DropForeignKey(
name: "fk_antispamignore_antispamsetting_antispamsettingid",
table: "antispamignore");
migrationBuilder.DropForeignKey(
name: "fk_antispamsetting_guildconfigs_guildconfigid",
table: "antispamsetting");
migrationBuilder.DropForeignKey(
name: "fk_commandalias_guildconfigs_guildconfigid",
table: "commandalias");
migrationBuilder.DropForeignKey(
name: "fk_commandcooldown_guildconfigs_guildconfigid",
table: "commandcooldown");
migrationBuilder.DropForeignKey(
name: "fk_delmsgoncmdchannel_guildconfigs_guildconfigid",
table: "delmsgoncmdchannel");
migrationBuilder.DropForeignKey(
name: "fk_excludeditem_xpsettings_xpsettingsid",
table: "excludeditem");
migrationBuilder.DropForeignKey(
name: "fk_filterchannelid_guildconfigs_guildconfigid",
table: "filterchannelid");
migrationBuilder.DropForeignKey(
name: "fk_filteredword_guildconfigs_guildconfigid",
table: "filteredword");
migrationBuilder.DropForeignKey(
name: "fk_filterlinkschannelid_guildconfigs_guildconfigid",
table: "filterlinkschannelid");
migrationBuilder.DropForeignKey(
name: "fk_filterwordschannelid_guildconfigs_guildconfigid",
table: "filterwordschannelid");
migrationBuilder.DropForeignKey(
name: "fk_followedstream_guildconfigs_guildconfigid",
table: "followedstream");
migrationBuilder.DropForeignKey(
name: "fk_gcchannelid_guildconfigs_guildconfigid",
table: "gcchannelid");
migrationBuilder.DropForeignKey(
name: "fk_muteduserid_guildconfigs_guildconfigid",
table: "muteduserid");
migrationBuilder.DropForeignKey(
name: "fk_permissions_guildconfigs_guildconfigid",
table: "permissions");
migrationBuilder.DropForeignKey(
name: "fk_shopentry_guildconfigs_guildconfigid",
table: "shopentry");
migrationBuilder.DropForeignKey(
name: "fk_shopentryitem_shopentry_shopentryid",
table: "shopentryitem");
migrationBuilder.DropForeignKey(
name: "fk_slowmodeignoredrole_guildconfigs_guildconfigid",
table: "slowmodeignoredrole");
migrationBuilder.DropForeignKey(
name: "fk_slowmodeignoreduser_guildconfigs_guildconfigid",
table: "slowmodeignoreduser");
migrationBuilder.DropForeignKey(
name: "fk_streamroleblacklisteduser_streamrolesettings_streamrolesett~",
table: "streamroleblacklisteduser");
migrationBuilder.DropForeignKey(
name: "fk_streamrolewhitelisteduser_streamrolesettings_streamrolesett~",
table: "streamrolewhitelisteduser");
migrationBuilder.DropForeignKey(
name: "fk_unbantimer_guildconfigs_guildconfigid",
table: "unbantimer");
migrationBuilder.DropForeignKey(
name: "fk_unmutetimer_guildconfigs_guildconfigid",
table: "unmutetimer");
migrationBuilder.DropForeignKey(
name: "fk_unroletimer_guildconfigs_guildconfigid",
table: "unroletimer");
migrationBuilder.DropForeignKey(
name: "fk_vcroleinfo_guildconfigs_guildconfigid",
table: "vcroleinfo");
migrationBuilder.DropForeignKey(
name: "fk_warningpunishment_guildconfigs_guildconfigid",
table: "warningpunishment");
migrationBuilder.AlterColumn<int>(
name: "streamrolesettingsid",
table: "streamrolewhitelisteduser",
type: "integer",
nullable: true,
oldClrType: typeof(int),
oldType: "integer");
migrationBuilder.AlterColumn<int>(
name: "streamrolesettingsid",
table: "streamroleblacklisteduser",
type: "integer",
nullable: true,
oldClrType: typeof(int),
oldType: "integer");
migrationBuilder.AlterColumn<int>(
name: "guildconfigid",
table: "delmsgoncmdchannel",
type: "integer",
nullable: true,
oldClrType: typeof(int),
oldType: "integer");
migrationBuilder.CreateTable(
name: "ignoredvoicepresencechannels",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
logsettingid = table.Column<int>(type: "integer", nullable: true),
channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_ignoredvoicepresencechannels", x => x.id);
table.ForeignKey(
name: "fk_ignoredvoicepresencechannels_logsettings_logsettingid",
column: x => x.logsettingid,
principalTable: "logsettings",
principalColumn: "id");
});
migrationBuilder.CreateIndex(
name: "ix_ignoredvoicepresencechannels_logsettingid",
table: "ignoredvoicepresencechannels",
column: "logsettingid");
migrationBuilder.AddForeignKey(
name: "fk_antiraidsetting_guildconfigs_guildconfigid",
table: "antiraidsetting",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_antispamignore_antispamsetting_antispamsettingid",
table: "antispamignore",
column: "antispamsettingid",
principalTable: "antispamsetting",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_antispamsetting_guildconfigs_guildconfigid",
table: "antispamsetting",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "fk_commandalias_guildconfigs_guildconfigid",
table: "commandalias",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_commandcooldown_guildconfigs_guildconfigid",
table: "commandcooldown",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_delmsgoncmdchannel_guildconfigs_guildconfigid",
table: "delmsgoncmdchannel",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_excludeditem_xpsettings_xpsettingsid",
table: "excludeditem",
column: "xpsettingsid",
principalTable: "xpsettings",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_filterchannelid_guildconfigs_guildconfigid",
table: "filterchannelid",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_filteredword_guildconfigs_guildconfigid",
table: "filteredword",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_filterlinkschannelid_guildconfigs_guildconfigid",
table: "filterlinkschannelid",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_filterwordschannelid_guildconfigs_guildconfigid",
table: "filterwordschannelid",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_followedstream_guildconfigs_guildconfigid",
table: "followedstream",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_gcchannelid_guildconfigs_guildconfigid",
table: "gcchannelid",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_muteduserid_guildconfigs_guildconfigid",
table: "muteduserid",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_permissions_guildconfigs_guildconfigid",
table: "permissions",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_shopentry_guildconfigs_guildconfigid",
table: "shopentry",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_shopentryitem_shopentry_shopentryid",
table: "shopentryitem",
column: "shopentryid",
principalTable: "shopentry",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_slowmodeignoredrole_guildconfigs_guildconfigid",
table: "slowmodeignoredrole",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_slowmodeignoreduser_guildconfigs_guildconfigid",
table: "slowmodeignoreduser",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_streamroleblacklisteduser_streamrolesettings_streamrolesett~",
table: "streamroleblacklisteduser",
column: "streamrolesettingsid",
principalTable: "streamrolesettings",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_streamrolewhitelisteduser_streamrolesettings_streamrolesett~",
table: "streamrolewhitelisteduser",
column: "streamrolesettingsid",
principalTable: "streamrolesettings",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_unbantimer_guildconfigs_guildconfigid",
table: "unbantimer",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_unmutetimer_guildconfigs_guildconfigid",
table: "unmutetimer",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_unroletimer_guildconfigs_guildconfigid",
table: "unroletimer",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_vcroleinfo_guildconfigs_guildconfigid",
table: "vcroleinfo",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_warningpunishment_guildconfigs_guildconfigid",
table: "warningpunishment",
column: "guildconfigid",
principalTable: "guildconfigs",
principalColumn: "id");
}
}
}

View file

@ -672,7 +672,7 @@ namespace NadekoBot.Migrations.PostgreSql
.HasColumnType("timestamp without time zone")
.HasColumnName("dateadded");
b.Property<int?>("GuildConfigId")
b.Property<int>("GuildConfigId")
.HasColumnType("integer")
.HasColumnName("guildconfigid");
@ -1422,36 +1422,6 @@ namespace NadekoBot.Migrations.PostgreSql
b.ToTable("ignoredlogchannels", (string)null);
});
modelBuilder.Entity("NadekoBot.Db.Models.IgnoredVoicePresenceChannel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<decimal>("ChannelId")
.HasColumnType("numeric(20,0)")
.HasColumnName("channelid");
b.Property<DateTime?>("DateAdded")
.HasColumnType("timestamp without time zone")
.HasColumnName("dateadded");
b.Property<int?>("LogSettingId")
.HasColumnType("integer")
.HasColumnName("logsettingid");
b.HasKey("Id")
.HasName("pk_ignoredvoicepresencechannels");
b.HasIndex("LogSettingId")
.HasDatabaseName("ix_ignoredvoicepresencechannels_logsettingid");
b.ToTable("ignoredvoicepresencechannels", (string)null);
});
modelBuilder.Entity("NadekoBot.Db.Models.ImageOnlyChannel", b =>
{
b.Property<int>("Id")
@ -2507,7 +2477,7 @@ namespace NadekoBot.Migrations.PostgreSql
.HasColumnType("timestamp without time zone")
.HasColumnName("dateadded");
b.Property<int?>("StreamRoleSettingsId")
b.Property<int>("StreamRoleSettingsId")
.HasColumnType("integer")
.HasColumnName("streamrolesettingsid");
@ -2584,7 +2554,7 @@ namespace NadekoBot.Migrations.PostgreSql
.HasColumnType("timestamp without time zone")
.HasColumnName("dateadded");
b.Property<int?>("StreamRoleSettingsId")
b.Property<int>("StreamRoleSettingsId")
.HasColumnType("integer")
.HasColumnName("streamrolesettingsid");
@ -3223,14 +3193,12 @@ namespace NadekoBot.Migrations.PostgreSql
modelBuilder.Entity("NadekoBot.Db.Models.AntiRaidSetting", b =>
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", "GuildConfig")
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithOne("AntiRaidSetting")
.HasForeignKey("NadekoBot.Db.Models.AntiRaidSetting", "GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_antiraidsetting_guildconfigs_guildconfigid");
b.Navigation("GuildConfig");
});
modelBuilder.Entity("NadekoBot.Db.Models.AntiSpamIgnore", b =>
@ -3238,19 +3206,18 @@ namespace NadekoBot.Migrations.PostgreSql
b.HasOne("NadekoBot.Db.Models.AntiSpamSetting", null)
.WithMany("IgnoredChannels")
.HasForeignKey("AntiSpamSettingId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_antispamignore_antispamsetting_antispamsettingid");
});
modelBuilder.Entity("NadekoBot.Db.Models.AntiSpamSetting", b =>
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", "GuildConfig")
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithOne("AntiSpamSetting")
.HasForeignKey("NadekoBot.Db.Models.AntiSpamSetting", "GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_antispamsetting_guildconfigs_guildconfigid");
b.Navigation("GuildConfig");
});
modelBuilder.Entity("NadekoBot.Db.Models.AutoTranslateUser", b =>
@ -3323,6 +3290,7 @@ namespace NadekoBot.Migrations.PostgreSql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("CommandAliases")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_commandalias_guildconfigs_guildconfigid");
});
@ -3331,6 +3299,7 @@ namespace NadekoBot.Migrations.PostgreSql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("CommandCooldowns")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_commandcooldown_guildconfigs_guildconfigid");
});
@ -3339,6 +3308,8 @@ namespace NadekoBot.Migrations.PostgreSql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("DelMsgOnCmdChannels")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_delmsgoncmdchannel_guildconfigs_guildconfigid");
});
@ -3355,10 +3326,13 @@ namespace NadekoBot.Migrations.PostgreSql
modelBuilder.Entity("NadekoBot.Db.Models.ExcludedItem", b =>
{
b.HasOne("NadekoBot.Db.Models.XpSettings", null)
b.HasOne("NadekoBot.Db.Models.XpSettings", "XpSettings")
.WithMany("ExclusionList")
.HasForeignKey("XpSettingsId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_excludeditem_xpsettings_xpsettingsid");
b.Navigation("XpSettings");
});
modelBuilder.Entity("NadekoBot.Db.Models.FeedSub", b =>
@ -3378,6 +3352,7 @@ namespace NadekoBot.Migrations.PostgreSql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("FilterInvitesChannelIds")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_filterchannelid_guildconfigs_guildconfigid");
});
@ -3386,6 +3361,7 @@ namespace NadekoBot.Migrations.PostgreSql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("FilterLinksChannelIds")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_filterlinkschannelid_guildconfigs_guildconfigid");
});
@ -3394,6 +3370,7 @@ namespace NadekoBot.Migrations.PostgreSql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("FilterWordsChannelIds")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_filterwordschannelid_guildconfigs_guildconfigid");
});
@ -3402,6 +3379,7 @@ namespace NadekoBot.Migrations.PostgreSql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("FilteredWords")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_filteredword_guildconfigs_guildconfigid");
});
@ -3410,6 +3388,7 @@ namespace NadekoBot.Migrations.PostgreSql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("FollowedStreams")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_followedstream_guildconfigs_guildconfigid");
});
@ -3418,6 +3397,7 @@ namespace NadekoBot.Migrations.PostgreSql
b.HasOne("NadekoBot.Db.Models.GuildConfig", "GuildConfig")
.WithMany("GenerateCurrencyChannelIds")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_gcchannelid_guildconfigs_guildconfigid");
b.Navigation("GuildConfig");
@ -3457,21 +3437,12 @@ namespace NadekoBot.Migrations.PostgreSql
b.Navigation("LogSetting");
});
modelBuilder.Entity("NadekoBot.Db.Models.IgnoredVoicePresenceChannel", b =>
{
b.HasOne("NadekoBot.Db.Models.LogSetting", "LogSetting")
.WithMany()
.HasForeignKey("LogSettingId")
.HasConstraintName("fk_ignoredvoicepresencechannels_logsettings_logsettingid");
b.Navigation("LogSetting");
});
modelBuilder.Entity("NadekoBot.Db.Models.MutedUserId", b =>
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("MutedUsers")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_muteduserid_guildconfigs_guildconfigid");
});
@ -3480,6 +3451,7 @@ namespace NadekoBot.Migrations.PostgreSql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("Permissions")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_permissions_guildconfigs_guildconfigid");
});
@ -3497,6 +3469,7 @@ namespace NadekoBot.Migrations.PostgreSql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("ShopEntries")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_shopentry_guildconfigs_guildconfigid");
});
@ -3505,6 +3478,7 @@ namespace NadekoBot.Migrations.PostgreSql
b.HasOne("NadekoBot.Db.Models.ShopEntry", null)
.WithMany("Items")
.HasForeignKey("ShopEntryId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_shopentryitem_shopentry_shopentryid");
});
@ -3513,6 +3487,7 @@ namespace NadekoBot.Migrations.PostgreSql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("SlowmodeIgnoredRoles")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_slowmodeignoredrole_guildconfigs_guildconfigid");
});
@ -3521,15 +3496,20 @@ namespace NadekoBot.Migrations.PostgreSql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("SlowmodeIgnoredUsers")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_slowmodeignoreduser_guildconfigs_guildconfigid");
});
modelBuilder.Entity("NadekoBot.Db.Models.StreamRoleBlacklistedUser", b =>
{
b.HasOne("NadekoBot.Db.Models.StreamRoleSettings", null)
b.HasOne("NadekoBot.Db.Models.StreamRoleSettings", "StreamRoleSettings")
.WithMany("Blacklist")
.HasForeignKey("StreamRoleSettingsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_streamroleblacklisteduser_streamrolesettings_streamrolesett~");
b.Navigation("StreamRoleSettings");
});
modelBuilder.Entity("NadekoBot.Db.Models.StreamRoleSettings", b =>
@ -3546,10 +3526,14 @@ namespace NadekoBot.Migrations.PostgreSql
modelBuilder.Entity("NadekoBot.Db.Models.StreamRoleWhitelistedUser", b =>
{
b.HasOne("NadekoBot.Db.Models.StreamRoleSettings", null)
b.HasOne("NadekoBot.Db.Models.StreamRoleSettings", "StreamRoleSettings")
.WithMany("Whitelist")
.HasForeignKey("StreamRoleSettingsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_streamrolewhitelisteduser_streamrolesettings_streamrolesett~");
b.Navigation("StreamRoleSettings");
});
modelBuilder.Entity("NadekoBot.Db.Models.TodoModel", b =>
@ -3566,6 +3550,7 @@ namespace NadekoBot.Migrations.PostgreSql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("UnbanTimer")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_unbantimer_guildconfigs_guildconfigid");
});
@ -3574,6 +3559,7 @@ namespace NadekoBot.Migrations.PostgreSql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("UnmuteTimers")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_unmutetimer_guildconfigs_guildconfigid");
});
@ -3582,6 +3568,7 @@ namespace NadekoBot.Migrations.PostgreSql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("UnroleTimer")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_unroletimer_guildconfigs_guildconfigid");
});
@ -3590,6 +3577,7 @@ namespace NadekoBot.Migrations.PostgreSql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("VcRoleInfos")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_vcroleinfo_guildconfigs_guildconfigid");
});
@ -3660,6 +3648,7 @@ namespace NadekoBot.Migrations.PostgreSql
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("WarnPunishments")
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("fk_warningpunishment_guildconfigs_guildconfigid");
});

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,701 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace NadekoBot.Migrations
{
/// <inheritdoc />
public partial class guidlconfigcleanup : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AntiRaidSetting_GuildConfigs_GuildConfigId",
table: "AntiRaidSetting");
migrationBuilder.DropForeignKey(
name: "FK_AntiSpamIgnore_AntiSpamSetting_AntiSpamSettingId",
table: "AntiSpamIgnore");
migrationBuilder.DropForeignKey(
name: "FK_AntiSpamSetting_GuildConfigs_GuildConfigId",
table: "AntiSpamSetting");
migrationBuilder.DropForeignKey(
name: "FK_CommandAlias_GuildConfigs_GuildConfigId",
table: "CommandAlias");
migrationBuilder.DropForeignKey(
name: "FK_CommandCooldown_GuildConfigs_GuildConfigId",
table: "CommandCooldown");
migrationBuilder.DropForeignKey(
name: "FK_DelMsgOnCmdChannel_GuildConfigs_GuildConfigId",
table: "DelMsgOnCmdChannel");
migrationBuilder.DropForeignKey(
name: "FK_ExcludedItem_XpSettings_XpSettingsId",
table: "ExcludedItem");
migrationBuilder.DropForeignKey(
name: "FK_FilterChannelId_GuildConfigs_GuildConfigId",
table: "FilterChannelId");
migrationBuilder.DropForeignKey(
name: "FK_FilteredWord_GuildConfigs_GuildConfigId",
table: "FilteredWord");
migrationBuilder.DropForeignKey(
name: "FK_FilterLinksChannelId_GuildConfigs_GuildConfigId",
table: "FilterLinksChannelId");
migrationBuilder.DropForeignKey(
name: "FK_FilterWordsChannelId_GuildConfigs_GuildConfigId",
table: "FilterWordsChannelId");
migrationBuilder.DropForeignKey(
name: "FK_FollowedStream_GuildConfigs_GuildConfigId",
table: "FollowedStream");
migrationBuilder.DropForeignKey(
name: "FK_GCChannelId_GuildConfigs_GuildConfigId",
table: "GCChannelId");
migrationBuilder.DropForeignKey(
name: "FK_MutedUserId_GuildConfigs_GuildConfigId",
table: "MutedUserId");
migrationBuilder.DropForeignKey(
name: "FK_Permissions_GuildConfigs_GuildConfigId",
table: "Permissions");
migrationBuilder.DropForeignKey(
name: "FK_ShopEntry_GuildConfigs_GuildConfigId",
table: "ShopEntry");
migrationBuilder.DropForeignKey(
name: "FK_ShopEntryItem_ShopEntry_ShopEntryId",
table: "ShopEntryItem");
migrationBuilder.DropForeignKey(
name: "FK_SlowmodeIgnoredRole_GuildConfigs_GuildConfigId",
table: "SlowmodeIgnoredRole");
migrationBuilder.DropForeignKey(
name: "FK_SlowmodeIgnoredUser_GuildConfigs_GuildConfigId",
table: "SlowmodeIgnoredUser");
migrationBuilder.DropForeignKey(
name: "FK_StreamRoleBlacklistedUser_StreamRoleSettings_StreamRoleSettingsId",
table: "StreamRoleBlacklistedUser");
migrationBuilder.DropForeignKey(
name: "FK_StreamRoleWhitelistedUser_StreamRoleSettings_StreamRoleSettingsId",
table: "StreamRoleWhitelistedUser");
migrationBuilder.DropForeignKey(
name: "FK_UnbanTimer_GuildConfigs_GuildConfigId",
table: "UnbanTimer");
migrationBuilder.DropForeignKey(
name: "FK_UnmuteTimer_GuildConfigs_GuildConfigId",
table: "UnmuteTimer");
migrationBuilder.DropForeignKey(
name: "FK_UnroleTimer_GuildConfigs_GuildConfigId",
table: "UnroleTimer");
migrationBuilder.DropForeignKey(
name: "FK_VcRoleInfo_GuildConfigs_GuildConfigId",
table: "VcRoleInfo");
migrationBuilder.DropForeignKey(
name: "FK_WarningPunishment_GuildConfigs_GuildConfigId",
table: "WarningPunishment");
migrationBuilder.DropTable(
name: "IgnoredVoicePresenceCHannels");
migrationBuilder.AlterColumn<int>(
name: "StreamRoleSettingsId",
table: "StreamRoleWhitelistedUser",
type: "INTEGER",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "INTEGER",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "StreamRoleSettingsId",
table: "StreamRoleBlacklistedUser",
type: "INTEGER",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "INTEGER",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "GuildConfigId",
table: "DelMsgOnCmdChannel",
type: "INTEGER",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "INTEGER",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_AntiRaidSetting_GuildConfigs_GuildConfigId",
table: "AntiRaidSetting",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AntiSpamIgnore_AntiSpamSetting_AntiSpamSettingId",
table: "AntiSpamIgnore",
column: "AntiSpamSettingId",
principalTable: "AntiSpamSetting",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AntiSpamSetting_GuildConfigs_GuildConfigId",
table: "AntiSpamSetting",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_CommandAlias_GuildConfigs_GuildConfigId",
table: "CommandAlias",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_CommandCooldown_GuildConfigs_GuildConfigId",
table: "CommandCooldown",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_DelMsgOnCmdChannel_GuildConfigs_GuildConfigId",
table: "DelMsgOnCmdChannel",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_ExcludedItem_XpSettings_XpSettingsId",
table: "ExcludedItem",
column: "XpSettingsId",
principalTable: "XpSettings",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_FilterChannelId_GuildConfigs_GuildConfigId",
table: "FilterChannelId",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_FilteredWord_GuildConfigs_GuildConfigId",
table: "FilteredWord",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_FilterLinksChannelId_GuildConfigs_GuildConfigId",
table: "FilterLinksChannelId",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_FilterWordsChannelId_GuildConfigs_GuildConfigId",
table: "FilterWordsChannelId",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_FollowedStream_GuildConfigs_GuildConfigId",
table: "FollowedStream",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_GCChannelId_GuildConfigs_GuildConfigId",
table: "GCChannelId",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_MutedUserId_GuildConfigs_GuildConfigId",
table: "MutedUserId",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Permissions_GuildConfigs_GuildConfigId",
table: "Permissions",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_ShopEntry_GuildConfigs_GuildConfigId",
table: "ShopEntry",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_ShopEntryItem_ShopEntry_ShopEntryId",
table: "ShopEntryItem",
column: "ShopEntryId",
principalTable: "ShopEntry",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_SlowmodeIgnoredRole_GuildConfigs_GuildConfigId",
table: "SlowmodeIgnoredRole",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_SlowmodeIgnoredUser_GuildConfigs_GuildConfigId",
table: "SlowmodeIgnoredUser",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_StreamRoleBlacklistedUser_StreamRoleSettings_StreamRoleSettingsId",
table: "StreamRoleBlacklistedUser",
column: "StreamRoleSettingsId",
principalTable: "StreamRoleSettings",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_StreamRoleWhitelistedUser_StreamRoleSettings_StreamRoleSettingsId",
table: "StreamRoleWhitelistedUser",
column: "StreamRoleSettingsId",
principalTable: "StreamRoleSettings",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_UnbanTimer_GuildConfigs_GuildConfigId",
table: "UnbanTimer",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_UnmuteTimer_GuildConfigs_GuildConfigId",
table: "UnmuteTimer",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_UnroleTimer_GuildConfigs_GuildConfigId",
table: "UnroleTimer",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_VcRoleInfo_GuildConfigs_GuildConfigId",
table: "VcRoleInfo",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_WarningPunishment_GuildConfigs_GuildConfigId",
table: "WarningPunishment",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AntiRaidSetting_GuildConfigs_GuildConfigId",
table: "AntiRaidSetting");
migrationBuilder.DropForeignKey(
name: "FK_AntiSpamIgnore_AntiSpamSetting_AntiSpamSettingId",
table: "AntiSpamIgnore");
migrationBuilder.DropForeignKey(
name: "FK_AntiSpamSetting_GuildConfigs_GuildConfigId",
table: "AntiSpamSetting");
migrationBuilder.DropForeignKey(
name: "FK_CommandAlias_GuildConfigs_GuildConfigId",
table: "CommandAlias");
migrationBuilder.DropForeignKey(
name: "FK_CommandCooldown_GuildConfigs_GuildConfigId",
table: "CommandCooldown");
migrationBuilder.DropForeignKey(
name: "FK_DelMsgOnCmdChannel_GuildConfigs_GuildConfigId",
table: "DelMsgOnCmdChannel");
migrationBuilder.DropForeignKey(
name: "FK_ExcludedItem_XpSettings_XpSettingsId",
table: "ExcludedItem");
migrationBuilder.DropForeignKey(
name: "FK_FilterChannelId_GuildConfigs_GuildConfigId",
table: "FilterChannelId");
migrationBuilder.DropForeignKey(
name: "FK_FilteredWord_GuildConfigs_GuildConfigId",
table: "FilteredWord");
migrationBuilder.DropForeignKey(
name: "FK_FilterLinksChannelId_GuildConfigs_GuildConfigId",
table: "FilterLinksChannelId");
migrationBuilder.DropForeignKey(
name: "FK_FilterWordsChannelId_GuildConfigs_GuildConfigId",
table: "FilterWordsChannelId");
migrationBuilder.DropForeignKey(
name: "FK_FollowedStream_GuildConfigs_GuildConfigId",
table: "FollowedStream");
migrationBuilder.DropForeignKey(
name: "FK_GCChannelId_GuildConfigs_GuildConfigId",
table: "GCChannelId");
migrationBuilder.DropForeignKey(
name: "FK_MutedUserId_GuildConfigs_GuildConfigId",
table: "MutedUserId");
migrationBuilder.DropForeignKey(
name: "FK_Permissions_GuildConfigs_GuildConfigId",
table: "Permissions");
migrationBuilder.DropForeignKey(
name: "FK_ShopEntry_GuildConfigs_GuildConfigId",
table: "ShopEntry");
migrationBuilder.DropForeignKey(
name: "FK_ShopEntryItem_ShopEntry_ShopEntryId",
table: "ShopEntryItem");
migrationBuilder.DropForeignKey(
name: "FK_SlowmodeIgnoredRole_GuildConfigs_GuildConfigId",
table: "SlowmodeIgnoredRole");
migrationBuilder.DropForeignKey(
name: "FK_SlowmodeIgnoredUser_GuildConfigs_GuildConfigId",
table: "SlowmodeIgnoredUser");
migrationBuilder.DropForeignKey(
name: "FK_StreamRoleBlacklistedUser_StreamRoleSettings_StreamRoleSettingsId",
table: "StreamRoleBlacklistedUser");
migrationBuilder.DropForeignKey(
name: "FK_StreamRoleWhitelistedUser_StreamRoleSettings_StreamRoleSettingsId",
table: "StreamRoleWhitelistedUser");
migrationBuilder.DropForeignKey(
name: "FK_UnbanTimer_GuildConfigs_GuildConfigId",
table: "UnbanTimer");
migrationBuilder.DropForeignKey(
name: "FK_UnmuteTimer_GuildConfigs_GuildConfigId",
table: "UnmuteTimer");
migrationBuilder.DropForeignKey(
name: "FK_UnroleTimer_GuildConfigs_GuildConfigId",
table: "UnroleTimer");
migrationBuilder.DropForeignKey(
name: "FK_VcRoleInfo_GuildConfigs_GuildConfigId",
table: "VcRoleInfo");
migrationBuilder.DropForeignKey(
name: "FK_WarningPunishment_GuildConfigs_GuildConfigId",
table: "WarningPunishment");
migrationBuilder.AlterColumn<int>(
name: "StreamRoleSettingsId",
table: "StreamRoleWhitelistedUser",
type: "INTEGER",
nullable: true,
oldClrType: typeof(int),
oldType: "INTEGER");
migrationBuilder.AlterColumn<int>(
name: "StreamRoleSettingsId",
table: "StreamRoleBlacklistedUser",
type: "INTEGER",
nullable: true,
oldClrType: typeof(int),
oldType: "INTEGER");
migrationBuilder.AlterColumn<int>(
name: "GuildConfigId",
table: "DelMsgOnCmdChannel",
type: "INTEGER",
nullable: true,
oldClrType: typeof(int),
oldType: "INTEGER");
migrationBuilder.CreateTable(
name: "IgnoredVoicePresenceCHannels",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
LogSettingId = table.Column<int>(type: "INTEGER", nullable: true),
ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false),
DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_IgnoredVoicePresenceCHannels", x => x.Id);
table.ForeignKey(
name: "FK_IgnoredVoicePresenceCHannels_LogSettings_LogSettingId",
column: x => x.LogSettingId,
principalTable: "LogSettings",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_IgnoredVoicePresenceCHannels_LogSettingId",
table: "IgnoredVoicePresenceCHannels",
column: "LogSettingId");
migrationBuilder.AddForeignKey(
name: "FK_AntiRaidSetting_GuildConfigs_GuildConfigId",
table: "AntiRaidSetting",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AntiSpamIgnore_AntiSpamSetting_AntiSpamSettingId",
table: "AntiSpamIgnore",
column: "AntiSpamSettingId",
principalTable: "AntiSpamSetting",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_AntiSpamSetting_GuildConfigs_GuildConfigId",
table: "AntiSpamSetting",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_CommandAlias_GuildConfigs_GuildConfigId",
table: "CommandAlias",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_CommandCooldown_GuildConfigs_GuildConfigId",
table: "CommandCooldown",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_DelMsgOnCmdChannel_GuildConfigs_GuildConfigId",
table: "DelMsgOnCmdChannel",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_ExcludedItem_XpSettings_XpSettingsId",
table: "ExcludedItem",
column: "XpSettingsId",
principalTable: "XpSettings",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_FilterChannelId_GuildConfigs_GuildConfigId",
table: "FilterChannelId",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_FilteredWord_GuildConfigs_GuildConfigId",
table: "FilteredWord",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_FilterLinksChannelId_GuildConfigs_GuildConfigId",
table: "FilterLinksChannelId",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_FilterWordsChannelId_GuildConfigs_GuildConfigId",
table: "FilterWordsChannelId",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_FollowedStream_GuildConfigs_GuildConfigId",
table: "FollowedStream",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_GCChannelId_GuildConfigs_GuildConfigId",
table: "GCChannelId",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_MutedUserId_GuildConfigs_GuildConfigId",
table: "MutedUserId",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Permissions_GuildConfigs_GuildConfigId",
table: "Permissions",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_ShopEntry_GuildConfigs_GuildConfigId",
table: "ShopEntry",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_ShopEntryItem_ShopEntry_ShopEntryId",
table: "ShopEntryItem",
column: "ShopEntryId",
principalTable: "ShopEntry",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_SlowmodeIgnoredRole_GuildConfigs_GuildConfigId",
table: "SlowmodeIgnoredRole",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_SlowmodeIgnoredUser_GuildConfigs_GuildConfigId",
table: "SlowmodeIgnoredUser",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_StreamRoleBlacklistedUser_StreamRoleSettings_StreamRoleSettingsId",
table: "StreamRoleBlacklistedUser",
column: "StreamRoleSettingsId",
principalTable: "StreamRoleSettings",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_StreamRoleWhitelistedUser_StreamRoleSettings_StreamRoleSettingsId",
table: "StreamRoleWhitelistedUser",
column: "StreamRoleSettingsId",
principalTable: "StreamRoleSettings",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_UnbanTimer_GuildConfigs_GuildConfigId",
table: "UnbanTimer",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_UnmuteTimer_GuildConfigs_GuildConfigId",
table: "UnmuteTimer",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_UnroleTimer_GuildConfigs_GuildConfigId",
table: "UnroleTimer",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_VcRoleInfo_GuildConfigs_GuildConfigId",
table: "VcRoleInfo",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_WarningPunishment_GuildConfigs_GuildConfigId",
table: "WarningPunishment",
column: "GuildConfigId",
principalTable: "GuildConfigs",
principalColumn: "Id");
}
}
}

View file

@ -501,7 +501,7 @@ namespace NadekoBot.Migrations
b.Property<DateTime?>("DateAdded")
.HasColumnType("TEXT");
b.Property<int?>("GuildConfigId")
b.Property<int>("GuildConfigId")
.HasColumnType("INTEGER");
b.Property<bool>("State")
@ -1059,28 +1059,6 @@ namespace NadekoBot.Migrations
b.ToTable("IgnoredLogChannels");
});
modelBuilder.Entity("NadekoBot.Db.Models.IgnoredVoicePresenceChannel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<ulong>("ChannelId")
.HasColumnType("INTEGER");
b.Property<DateTime?>("DateAdded")
.HasColumnType("TEXT");
b.Property<int?>("LogSettingId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("LogSettingId");
b.ToTable("IgnoredVoicePresenceCHannels");
});
modelBuilder.Entity("NadekoBot.Db.Models.ImageOnlyChannel", b =>
{
b.Property<int>("Id")
@ -1867,7 +1845,7 @@ namespace NadekoBot.Migrations
b.Property<DateTime?>("DateAdded")
.HasColumnType("TEXT");
b.Property<int?>("StreamRoleSettingsId")
b.Property<int>("StreamRoleSettingsId")
.HasColumnType("INTEGER");
b.Property<ulong>("UserId")
@ -1924,7 +1902,7 @@ namespace NadekoBot.Migrations
b.Property<DateTime?>("DateAdded")
.HasColumnType("TEXT");
b.Property<int?>("StreamRoleSettingsId")
b.Property<int>("StreamRoleSettingsId")
.HasColumnType("INTEGER");
b.Property<ulong>("UserId")
@ -2397,31 +2375,28 @@ namespace NadekoBot.Migrations
modelBuilder.Entity("NadekoBot.Db.Models.AntiRaidSetting", b =>
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", "GuildConfig")
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithOne("AntiRaidSetting")
.HasForeignKey("NadekoBot.Db.Models.AntiRaidSetting", "GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("GuildConfig");
});
modelBuilder.Entity("NadekoBot.Db.Models.AntiSpamIgnore", b =>
{
b.HasOne("NadekoBot.Db.Models.AntiSpamSetting", null)
.WithMany("IgnoredChannels")
.HasForeignKey("AntiSpamSettingId");
.HasForeignKey("AntiSpamSettingId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("NadekoBot.Db.Models.AntiSpamSetting", b =>
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", "GuildConfig")
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithOne("AntiSpamSetting")
.HasForeignKey("NadekoBot.Db.Models.AntiSpamSetting", "GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("GuildConfig");
});
modelBuilder.Entity("NadekoBot.Db.Models.AutoTranslateUser", b =>
@ -2487,21 +2462,25 @@ namespace NadekoBot.Migrations
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("CommandAliases")
.HasForeignKey("GuildConfigId");
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("NadekoBot.Db.Models.CommandCooldown", b =>
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("CommandCooldowns")
.HasForeignKey("GuildConfigId");
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("NadekoBot.Db.Models.DelMsgOnCmdChannel", b =>
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("DelMsgOnCmdChannels")
.HasForeignKey("GuildConfigId");
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("NadekoBot.Db.Models.DiscordUser", b =>
@ -2516,9 +2495,12 @@ namespace NadekoBot.Migrations
modelBuilder.Entity("NadekoBot.Db.Models.ExcludedItem", b =>
{
b.HasOne("NadekoBot.Db.Models.XpSettings", null)
b.HasOne("NadekoBot.Db.Models.XpSettings", "XpSettings")
.WithMany("ExclusionList")
.HasForeignKey("XpSettingsId");
.HasForeignKey("XpSettingsId")
.OnDelete(DeleteBehavior.Cascade);
b.Navigation("XpSettings");
});
modelBuilder.Entity("NadekoBot.Db.Models.FeedSub", b =>
@ -2536,42 +2518,48 @@ namespace NadekoBot.Migrations
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("FilterInvitesChannelIds")
.HasForeignKey("GuildConfigId");
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("NadekoBot.Db.Models.FilterLinksChannelId", b =>
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("FilterLinksChannelIds")
.HasForeignKey("GuildConfigId");
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("NadekoBot.Db.Models.FilterWordsChannelId", b =>
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("FilterWordsChannelIds")
.HasForeignKey("GuildConfigId");
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("NadekoBot.Db.Models.FilteredWord", b =>
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("FilteredWords")
.HasForeignKey("GuildConfigId");
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("NadekoBot.Db.Models.FollowedStream", b =>
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("FollowedStreams")
.HasForeignKey("GuildConfigId");
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("NadekoBot.Db.Models.GCChannelId", b =>
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", "GuildConfig")
.WithMany("GenerateCurrencyChannelIds")
.HasForeignKey("GuildConfigId");
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade);
b.Navigation("GuildConfig");
});
@ -2607,27 +2595,20 @@ namespace NadekoBot.Migrations
b.Navigation("LogSetting");
});
modelBuilder.Entity("NadekoBot.Db.Models.IgnoredVoicePresenceChannel", b =>
{
b.HasOne("NadekoBot.Db.Models.LogSetting", "LogSetting")
.WithMany()
.HasForeignKey("LogSettingId");
b.Navigation("LogSetting");
});
modelBuilder.Entity("NadekoBot.Db.Models.MutedUserId", b =>
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("MutedUsers")
.HasForeignKey("GuildConfigId");
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("NadekoBot.Db.Models.Permissionv2", b =>
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("Permissions")
.HasForeignKey("GuildConfigId");
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("NadekoBot.Db.Models.PlaylistSong", b =>
@ -2642,35 +2623,43 @@ namespace NadekoBot.Migrations
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("ShopEntries")
.HasForeignKey("GuildConfigId");
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("NadekoBot.Db.Models.ShopEntryItem", b =>
{
b.HasOne("NadekoBot.Db.Models.ShopEntry", null)
.WithMany("Items")
.HasForeignKey("ShopEntryId");
.HasForeignKey("ShopEntryId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("NadekoBot.Db.Models.SlowmodeIgnoredRole", b =>
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("SlowmodeIgnoredRoles")
.HasForeignKey("GuildConfigId");
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("NadekoBot.Db.Models.SlowmodeIgnoredUser", b =>
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("SlowmodeIgnoredUsers")
.HasForeignKey("GuildConfigId");
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("NadekoBot.Db.Models.StreamRoleBlacklistedUser", b =>
{
b.HasOne("NadekoBot.Db.Models.StreamRoleSettings", null)
b.HasOne("NadekoBot.Db.Models.StreamRoleSettings", "StreamRoleSettings")
.WithMany("Blacklist")
.HasForeignKey("StreamRoleSettingsId");
.HasForeignKey("StreamRoleSettingsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("StreamRoleSettings");
});
modelBuilder.Entity("NadekoBot.Db.Models.StreamRoleSettings", b =>
@ -2686,9 +2675,13 @@ namespace NadekoBot.Migrations
modelBuilder.Entity("NadekoBot.Db.Models.StreamRoleWhitelistedUser", b =>
{
b.HasOne("NadekoBot.Db.Models.StreamRoleSettings", null)
b.HasOne("NadekoBot.Db.Models.StreamRoleSettings", "StreamRoleSettings")
.WithMany("Whitelist")
.HasForeignKey("StreamRoleSettingsId");
.HasForeignKey("StreamRoleSettingsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("StreamRoleSettings");
});
modelBuilder.Entity("NadekoBot.Db.Models.TodoModel", b =>
@ -2703,28 +2696,32 @@ namespace NadekoBot.Migrations
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("UnbanTimer")
.HasForeignKey("GuildConfigId");
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("NadekoBot.Db.Models.UnmuteTimer", b =>
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("UnmuteTimers")
.HasForeignKey("GuildConfigId");
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("NadekoBot.Db.Models.UnroleTimer", b =>
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("UnroleTimer")
.HasForeignKey("GuildConfigId");
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("NadekoBot.Db.Models.VcRoleInfo", b =>
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("VcRoleInfos")
.HasForeignKey("GuildConfigId");
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("NadekoBot.Db.Models.WaifuInfo", b =>
@ -2786,7 +2783,8 @@ namespace NadekoBot.Migrations
{
b.HasOne("NadekoBot.Db.Models.GuildConfig", null)
.WithMany("WarnPunishments")
.HasForeignKey("GuildConfigId");
.HasForeignKey("GuildConfigId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("NadekoBot.Db.Models.XpCurrencyReward", b =>

View file

@ -0,0 +1,31 @@
namespace NadekoBot.Modules.Administration.DangerousCommands;
public partial class Administration
{
[Group]
public class CleanupCommands : CleanupModuleBase
{
private readonly ICleanupService _svc;
public CleanupCommands(ICleanupService svc)
=> _svc = svc;
[Cmd]
[OwnerOnly]
[RequireContext(ContextType.DM)]
public async Task CleanupGuildData()
{
var result = await _svc.DeleteMissingGuildDataAsync();
if (result is null)
{
await ctx.ErrorAsync();
return;
}
await Response()
.Confirm($"{result.GuildCount} guilds' data remain in the database.")
.SendAsync();
}
}
}

View file

@ -0,0 +1,106 @@
using LinqToDB;
using LinqToDB.Data;
using LinqToDB.EntityFrameworkCore;
using NadekoBot.Common.ModuleBehaviors;
using NadekoBot.Db.Models;
namespace NadekoBot.Modules.Administration.DangerousCommands;
public sealed class CleanupService : ICleanupService, IReadyExecutor, INService
{
private readonly IPubSub _pubSub;
private TypedKey<KeepReport> _keepReportKey = new("cleanup:report");
private TypedKey<bool> _keepTriggerKey = new("cleanup:trigger");
private readonly DiscordSocketClient _client;
private ConcurrentDictionary<int, ulong[]> guildIds;
private readonly IBotCredsProvider _creds;
private readonly DbService _db;
public CleanupService(
IPubSub pubSub,
DiscordSocketClient client,
IBotCredsProvider creds,
DbService db)
{
_pubSub = pubSub;
_client = client;
_creds = creds;
_db = db;
}
public async Task<KeepResult?> DeleteMissingGuildDataAsync()
{
guildIds = new();
var totalShards = _creds.GetCreds().TotalShards;
await _pubSub.Pub(_keepTriggerKey, true);
var counter = 0;
while (guildIds.Keys.Count < totalShards)
{
await Task.Delay(1000);
counter++;
if (counter >= 5)
break;
}
if (guildIds.Keys.Count < totalShards)
return default;
var allIds = guildIds.SelectMany(x => x.Value)
.ToArray();
await using var ctx = _db.GetDbContext();
await using var linqCtx = ctx.CreateLinqToDBContext();
await using var tempTable = linqCtx.CreateTempTable<CleanupId>();
foreach (var chunk in allIds.Chunk(20000))
{
await tempTable.BulkCopyAsync(chunk.Select(x => new CleanupId()
{
GuildId = x
}));
}
await ctx.GetTable<GuildConfig>()
.Where(x => !tempTable.Select(x => x.GuildId)
.Contains(x.GuildId))
.DeleteAsync();
await ctx.GetTable<UserXpStats>()
.Where(x => !tempTable.Select(x => x.GuildId)
.Contains(x.GuildId))
.DeleteAsync();
return new()
{
GuildCount = guildIds.Keys.Count,
};
}
private ValueTask OnKeepReport(KeepReport report)
{
guildIds[report.ShardId] = report.GuildIds;
return default;
}
public async Task OnReadyAsync()
{
await _pubSub.Sub(_keepTriggerKey, OnKeepTrigger);
if (_client.ShardId == 0)
await _pubSub.Sub(_keepReportKey, OnKeepReport);
}
private ValueTask OnKeepTrigger(bool arg)
{
_pubSub.Pub(_keepReportKey,
new KeepReport()
{
ShardId = _client.ShardId,
GuildIds = _client.GetGuildIds(),
});
return default;
}
}

View file

@ -0,0 +1,9 @@
using System.ComponentModel.DataAnnotations;
namespace NadekoBot.Modules.Administration.DangerousCommands;
public sealed class CleanupId
{
[Key]
public ulong GuildId { get; set; }
}

View file

@ -0,0 +1,6 @@
namespace NadekoBot.Modules.Administration.DangerousCommands;
public interface ICleanupService
{
Task<KeepResult?> DeleteMissingGuildDataAsync();
}

View file

@ -0,0 +1,7 @@
namespace NadekoBot.Modules.Administration.DangerousCommands;
public sealed class KeepReport
{
public required int ShardId { get; init; }
public required ulong[] GuildIds { get; init; }
}

View file

@ -0,0 +1,6 @@
namespace NadekoBot.Modules.Administration.DangerousCommands;
public sealed class KeepResult
{
public required int GuildCount { get; init; }
}

View file

@ -489,17 +489,9 @@ public sealed partial class Help : NadekoModule<HelpService>
**Step 3** Wait a short while (usually 1-3 minutes)
Nadeko will DM you the welcome instructions, and you may will receive your rewards!
Nadeko will DM you the welcome instructions, and you will receive your rewards!
🎉 **Enjoy!** 🎉
""")
.AddField("Troubleshooting",
"""
*In case you didn't receive the rewards within 5 minutes:*
`1.` Make sure your DMs are open to everyone. Maybe your pledge was processed successfully but the bot was unable to DM you. Use the `.patron` command to check your status.
`2.` Make sure you've connected the CORRECT Discord account. Quite often users log in to different Discord accounts in their browser. You may also try disconnecting and reconnecting your account.
`3.` Make sure your payment has been processed and not declined by Patreon.
`4.` If any of the previous steps don't help, you can join the nadeko support server <https://discord.nadeko.bot> and ask for help in the #help channel
""");
""");
try
{

View file

@ -4440,3 +4440,11 @@ todoarchivedelete:
params:
- todoId:
desc: "The identifier for the archived todo item to be deleted."
cleanupguilddata:
desc: |-
Deletes data for all servers bot is no longer a member of from the database.
This is a highly destructive and irreversible command.
ex:
- ''
params:
- {}