forked from discord-csharp/MODiX
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaround for bogus tables generated by keyless entities.
- Loading branch information
1 parent
a34fce0
commit 6c80d44
Showing
11 changed files
with
1,198 additions
and
143 deletions.
There are no files selected for viewing
1,032 changes: 1,032 additions & 0 deletions
1,032
Modix.Data/Migrations/20200222024643_RemoveBogusKeylessEntityTables.Designer.cs
Large diffs are not rendered by default.
Oops, something went wrong.
63 changes: 63 additions & 0 deletions
63
Modix.Data/Migrations/20200222024643_RemoveBogusKeylessEntityTables.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
namespace Modix.Data.Migrations | ||
{ | ||
public partial class RemoveBogusKeylessEntityTables : Migration | ||
{ | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
// EmojiStatsDto table was never actually create in any prior migration, even though the ModelSnapshots say it should be there. | ||
|
||
// GuildEmojiStats table was never actually create in any prior migration, even though the ModelSnapshots say it should be there. | ||
|
||
// GuildUserParticipationStatistics table was never actually create in any prior migration, even though the ModelSnapshots say it should be there. | ||
|
||
migrationBuilder.DropTable( | ||
name: "MessageCountByDate"); | ||
|
||
migrationBuilder.DropTable( | ||
name: "MessageCountPerChannel"); | ||
|
||
// PerUserMessageCount table was never actually create in any prior migration, even though the ModelSnapshots say it should be there. | ||
|
||
// SingleEmojiStatsDto table was never actually create in any prior migration, even though the ModelSnapshots say it should be there. | ||
} | ||
|
||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
// EmojiStatsDto table was never actually create in any prior migration, even though the ModelSnapshots say it should be there. | ||
|
||
// GuildEmojiStats table was never actually create in any prior migration, even though the ModelSnapshots say it should be there. | ||
|
||
// GuildUserParticipationStatistics table was never actually create in any prior migration, even though the ModelSnapshots say it should be there. | ||
|
||
migrationBuilder.CreateTable( | ||
name: "MessageCountByDate", | ||
columns: table => new | ||
{ | ||
Date = table.Column<DateTime>(type: "timestamp without time zone", nullable: false), | ||
MessageCount = table.Column<int>(type: "integer", nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
}); | ||
|
||
migrationBuilder.CreateTable( | ||
name: "MessageCountPerChannel", | ||
columns: table => new | ||
{ | ||
ChannelId = table.Column<decimal>(type: "numeric(20,0)", nullable: false), | ||
ChannelName = table.Column<string>(type: "text", nullable: false), | ||
MessageCount = table.Column<int>(type: "integer", nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
}); | ||
|
||
// PerUserMessageCount table was never actually create in any prior migration, even though the ModelSnapshots say it should be there. | ||
|
||
// SingleEmojiStatsDto table was never actually create in any prior migration, even though the ModelSnapshots say it should be there. | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,23 @@ | ||
namespace Modix.Data.Models.Core | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Modix.Data.Models.Core | ||
{ | ||
public class MessageCountPerChannel | ||
{ | ||
public ulong ChannelId { get; set; } | ||
public string ChannelName { get; set; } = null!; | ||
public int MessageCount { get; set; } | ||
} | ||
|
||
public class MessageCountPerChannelConfiguration | ||
: IEntityTypeConfiguration<MessageCountPerChannel> | ||
{ | ||
public void Configure( | ||
EntityTypeBuilder<MessageCountPerChannel> entityTypeBuilder) | ||
=> entityTypeBuilder | ||
.HasNoKey() | ||
// Workaround until .NET 5: https://github.com/dotnet/efcore/issues/19972 | ||
.ToView("No table or view exists for entity type MessageCountPerChannel: This type can only be queried with raw SQL (.FromSqlXXX())"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.