Re-did migration as the old one was wrong

This commit is contained in:
Kwoth
2021-09-21 22:48:18 +02:00
parent c9e89e1911
commit 453ac3efd2
5 changed files with 47 additions and 23 deletions

View File

@@ -2,6 +2,7 @@
{
public class IgnoredLogItem : DbEntity
{
public int LogSettingId { get; set; }
public LogSetting LogSetting { get; set; }
public ulong LogItemId { get; set; }
public IgnoredItemType ItemType { get; set; }

View File

@@ -349,7 +349,7 @@ namespace NadekoBot.Services.Database
.OnDelete(DeleteBehavior.Cascade));
modelBuilder.Entity<IgnoredLogItem>(ili => ili
.HasIndex(x => new { ItemId = x.LogItemId, x.ItemType })
.HasIndex(x => new { x.LogSettingId, x.LogItemId, x.ItemType })
.IsUnique());
#endregion

View File

@@ -9,8 +9,8 @@ using NadekoBot.Services.Database;
namespace NadekoBot.Migrations
{
[DbContext(typeof(NadekoContext))]
[Migration("20210921194708_logignore-user-role-channel")]
partial class logignoreuserrolechannel
[Migration("20210921204645_logignore-user-channel")]
partial class logignoreuserchannel
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
@@ -864,14 +864,12 @@ namespace NadekoBot.Migrations
b.Property<ulong>("LogItemId")
.HasColumnType("INTEGER");
b.Property<int?>("LogSettingId")
b.Property<int>("LogSettingId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("LogSettingId");
b.HasIndex("LogItemId", "ItemType")
b.HasIndex("LogSettingId", "LogItemId", "ItemType")
.IsUnique();
b.ToTable("IgnoredLogChannels");
@@ -2282,7 +2280,8 @@ namespace NadekoBot.Migrations
b.HasOne("NadekoBot.Services.Database.Models.LogSetting", "LogSetting")
.WithMany("LogIgnores")
.HasForeignKey("LogSettingId")
.OnDelete(DeleteBehavior.Cascade);
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("LogSetting");
});
@@ -2290,7 +2289,7 @@ namespace NadekoBot.Migrations
modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredVoicePresenceChannel", b =>
{
b.HasOne("NadekoBot.Services.Database.Models.LogSetting", "LogSetting")
.WithMany("IgnoredVoicePresenceChannelIds")
.WithMany()
.HasForeignKey("LogSettingId");
b.Navigation("LogSetting");
@@ -2607,8 +2606,6 @@ namespace NadekoBot.Migrations
modelBuilder.Entity("NadekoBot.Services.Database.Models.LogSetting", b =>
{
b.Navigation("IgnoredVoicePresenceChannelIds");
b.Navigation("LogIgnores");
});

View File

@@ -2,19 +2,35 @@
namespace NadekoBot.Migrations
{
public partial class logignoreuserrolechannel : Migration
public partial class logignoreuserchannel : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("DELETE FROM IgnoredLogChannels WHERE LogSettingId is NULL");
migrationBuilder.DropForeignKey(
name: "FK_IgnoredLogChannels_LogSettings_LogSettingId",
table: "IgnoredLogChannels");
migrationBuilder.DropIndex(
name: "IX_IgnoredLogChannels_LogSettingId",
table: "IgnoredLogChannels");
migrationBuilder.RenameColumn(
name: "ChannelId",
table: "IgnoredLogChannels",
newName: "LogItemId");
migrationBuilder.AlterColumn<int>(
name: "LogSettingId",
table: "IgnoredLogChannels",
type: "INTEGER",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "INTEGER",
oldNullable: true);
migrationBuilder.AddColumn<int>(
name: "ItemType",
table: "IgnoredLogChannels",
@@ -23,9 +39,9 @@ namespace NadekoBot.Migrations
defaultValue: 0);
migrationBuilder.CreateIndex(
name: "IX_IgnoredLogChannels_LogItemId_ItemType",
name: "IX_IgnoredLogChannels_LogSettingId_LogItemId_ItemType",
table: "IgnoredLogChannels",
columns: new[] { "LogItemId", "ItemType" },
columns: new[] { "LogSettingId", "LogItemId", "ItemType" },
unique: true);
migrationBuilder.AddForeignKey(
@@ -44,7 +60,7 @@ namespace NadekoBot.Migrations
table: "IgnoredLogChannels");
migrationBuilder.DropIndex(
name: "IX_IgnoredLogChannels_LogItemId_ItemType",
name: "IX_IgnoredLogChannels_LogSettingId_LogItemId_ItemType",
table: "IgnoredLogChannels");
migrationBuilder.DropColumn(
@@ -56,6 +72,19 @@ namespace NadekoBot.Migrations
table: "IgnoredLogChannels",
newName: "ChannelId");
migrationBuilder.AlterColumn<int>(
name: "LogSettingId",
table: "IgnoredLogChannels",
type: "INTEGER",
nullable: true,
oldClrType: typeof(int),
oldType: "INTEGER");
migrationBuilder.CreateIndex(
name: "IX_IgnoredLogChannels_LogSettingId",
table: "IgnoredLogChannels",
column: "LogSettingId");
migrationBuilder.AddForeignKey(
name: "FK_IgnoredLogChannels_LogSettings_LogSettingId",
table: "IgnoredLogChannels",

View File

@@ -862,14 +862,12 @@ namespace NadekoBot.Migrations
b.Property<ulong>("LogItemId")
.HasColumnType("INTEGER");
b.Property<int?>("LogSettingId")
b.Property<int>("LogSettingId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("LogSettingId");
b.HasIndex("LogItemId", "ItemType")
b.HasIndex("LogSettingId", "LogItemId", "ItemType")
.IsUnique();
b.ToTable("IgnoredLogChannels");
@@ -2280,7 +2278,8 @@ namespace NadekoBot.Migrations
b.HasOne("NadekoBot.Services.Database.Models.LogSetting", "LogSetting")
.WithMany("LogIgnores")
.HasForeignKey("LogSettingId")
.OnDelete(DeleteBehavior.Cascade);
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("LogSetting");
});
@@ -2288,7 +2287,7 @@ namespace NadekoBot.Migrations
modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredVoicePresenceChannel", b =>
{
b.HasOne("NadekoBot.Services.Database.Models.LogSetting", "LogSetting")
.WithMany("IgnoredVoicePresenceChannelIds")
.WithMany()
.HasForeignKey("LogSettingId");
b.Navigation("LogSetting");
@@ -2605,8 +2604,6 @@ namespace NadekoBot.Migrations
modelBuilder.Entity("NadekoBot.Services.Database.Models.LogSetting", b =>
{
b.Navigation("IgnoredVoicePresenceChannelIds");
b.Navigation("LogIgnores");
});