new migration

This commit is contained in:
Toastie 2025-02-03 13:35:21 +13:00
parent 0e2e9c0ec6
commit 8a9e117366
Signed by: toastie_t0ast
GPG key ID: 0861BE54AD481DC7
10 changed files with 150 additions and 83 deletions

View file

@ -27,13 +27,13 @@
<PrivateAssets>all</PrivateAssets>
<Publish>True</Publish>
</PackageReference>
<PackageReference Include="CodeHollow.FeedReader" Version="1.2.6"/>
<PackageReference Include="CommandLineParser" Version="2.9.1"/>
<PackageReference Include="CodeHollow.FeedReader" Version="1.2.6" />
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Discord.Net" Version="3.17.1" />
<PackageReference Include="CoreCLR-NCalc" Version="3.1.253" />
<PackageReference Include="Google.Apis.Urlshortener.v1" Version="1.41.1.138"/>
<PackageReference Include="Google.Apis.Urlshortener.v1" Version="1.41.1.138" />
<PackageReference Include="Google.Apis.YouTube.v3" Version="1.68.0.3653" />
<PackageReference Include="Google.Apis.Customsearch.v1" Version="1.49.0.2084"/>
<PackageReference Include="Google.Apis.Customsearch.v1" Version="1.49.0.2084" />
<PackageReference Include="Google.Protobuf" Version="3.29.3" />
<PackageReference Include="Grpc" Version="2.46.6" />
@ -46,23 +46,23 @@
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.1" />
<PackageReference Include="MorseCode.ITask" Version="2.0.3"/>
<PackageReference Include="NetEscapades.Configuration.Yaml" Version="3.1.0"/>
<PackageReference Include="MorseCode.ITask" Version="2.0.3" />
<PackageReference Include="NetEscapades.Configuration.Yaml" Version="3.1.0" />
<!-- DI -->
<!-- <PackageReference Include="Ninject" Version="3.3.6"/>-->
<!-- <PackageReference Include="Ninject.Extensions.Conventions" Version="3.3.0"/>-->
<!-- <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />-->
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.1" />
<PackageReference Include="DryIoc.dll" Version="5.4.3"/>
<PackageReference Include="DryIoc.dll" Version="5.4.3" />
<!-- <PackageReference Include="Scrutor" Version="4.2.0" />-->
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.1" />
<PackageReference Include="Microsoft.SyndicationFeed.ReaderWriter" Version="1.0.2"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
<PackageReference Include="NonBlocking" Version="2.1.2"/>
<PackageReference Include="Microsoft.SyndicationFeed.ReaderWriter" Version="1.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NonBlocking" Version="2.1.2" />
<PackageReference Include="OneOf" Version="3.0.271" />
<PackageReference Include="OneOf.SourceGenerator" Version="3.0.271" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
@ -71,10 +71,10 @@
<PackageReference Include="SixLabors.Fonts" Version="2.1.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.6" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.1.5" />
<PackageReference Include="SixLabors.Shapes" Version="1.0.0-beta0009"/>
<PackageReference Include="SixLabors.Shapes" Version="1.0.0-beta0009" />
<PackageReference Include="StackExchange.Redis" Version="2.8.24" />
<PackageReference Include="YamlDotNet" Version="15.1.6" />
<PackageReference Include="SharpToken" Version="2.0.3"/>
<PackageReference Include="SharpToken" Version="2.0.3" />
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0" />
@ -112,6 +112,10 @@
<AdditionalFiles Include="strings\responses\responses.en-US.json" />
</ItemGroup>
<ItemGroup>
<Compile Include="Migrations\Sqlite\20250202095042_fk-remove.sql" />
</ItemGroup>
<ItemGroup>
<None Update="data\**\*">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>

View file

@ -0,0 +1,18 @@
START TRANSACTION;
ALTER TABLE xpsettings DROP COLUMN guildconfigid;
ALTER TABLE feedsub DROP COLUMN guildconfigid;
ALTER TABLE delmsgoncmdchannel DROP COLUMN guildconfigid;
ALTER TABLE antiraidsetting DROP COLUMN guildconfigid;
UPDATE filteredword SET word = '' WHERE word IS NULL;
ALTER TABLE filteredword ALTER COLUMN word SET NOT NULL;
ALTER TABLE filteredword ALTER COLUMN word SET DEFAULT '';
INSERT INTO "__EFMigrationsHistory" (migrationid, productversion)
VALUES ('20250202095045_fk-remove', '9.0.1');
COMMIT;

View file

@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace EllieBot.Migrations.PostgreSql
{
[DbContext(typeof(PostgreSqlContext))]
[Migration("20250127062816_init")]
[Migration("20250202095110_init")]
partial class init
{
/// <inheritdoc />
@ -85,10 +85,6 @@ namespace EllieBot.Migrations.PostgreSql
.HasColumnType("timestamp without time zone")
.HasColumnName("dateadded");
b.Property<int>("GuildConfigId")
.HasColumnType("integer")
.HasColumnName("guildconfigid");
b.Property<decimal>("GuildId")
.HasColumnType("numeric(20,0)")
.HasColumnName("guildid");
@ -751,10 +747,6 @@ namespace EllieBot.Migrations.PostgreSql
.HasColumnType("timestamp without time zone")
.HasColumnName("dateadded");
b.Property<int>("GuildConfigId")
.HasColumnType("integer")
.HasColumnName("guildconfigid");
b.Property<decimal>("GuildId")
.HasColumnType("numeric(20,0)")
.HasColumnName("guildid");
@ -936,10 +928,6 @@ namespace EllieBot.Migrations.PostgreSql
.HasColumnType("timestamp without time zone")
.HasColumnName("dateadded");
b.Property<int>("GuildConfigId")
.HasColumnType("integer")
.HasColumnName("guildconfigid");
b.Property<decimal>("GuildId")
.HasColumnType("numeric(20,0)")
.HasColumnName("guildid");
@ -1066,6 +1054,7 @@ namespace EllieBot.Migrations.PostgreSql
.HasColumnName("guildfilterconfigid");
b.Property<string>("Word")
.IsRequired()
.HasColumnType("text")
.HasColumnName("word");
@ -3367,10 +3356,6 @@ namespace EllieBot.Migrations.PostgreSql
.HasColumnType("timestamp without time zone")
.HasColumnName("dateadded");
b.Property<int>("GuildConfigId")
.HasColumnType("integer")
.HasColumnName("guildconfigid");
b.Property<decimal>("GuildId")
.HasColumnType("numeric(20,0)")
.HasColumnName("guildid");

View file

@ -36,7 +36,6 @@ namespace EllieBot.Migrations.PostgreSql
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
guildconfigid = table.Column<int>(type: "integer", nullable: false),
guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
userthreshold = table.Column<int>(type: "integer", nullable: false),
seconds = table.Column<int>(type: "integer", nullable: false),
@ -245,7 +244,6 @@ namespace EllieBot.Migrations.PostgreSql
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
guildconfigid = table.Column<int>(type: "integer", nullable: false),
guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
state = table.Column<bool>(type: "boolean", nullable: false),
@ -299,7 +297,6 @@ namespace EllieBot.Migrations.PostgreSql
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
guildconfigid = table.Column<int>(type: "integer", nullable: false),
guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
url = table.Column<string>(type: "text", nullable: true),
@ -1120,7 +1117,6 @@ namespace EllieBot.Migrations.PostgreSql
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
guildconfigid = table.Column<int>(type: "integer", nullable: false),
guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
serverexcluded = table.Column<bool>(type: "boolean", nullable: false),
dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
@ -1265,7 +1261,7 @@ namespace EllieBot.Migrations.PostgreSql
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
word = table.Column<string>(type: "text", nullable: true),
word = table.Column<string>(type: "text", nullable: false),
guildfilterconfigid = table.Column<int>(type: "integer", nullable: true),
dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
},

View file

@ -82,10 +82,6 @@ namespace EllieBot.Migrations.PostgreSql
.HasColumnType("timestamp without time zone")
.HasColumnName("dateadded");
b.Property<int>("GuildConfigId")
.HasColumnType("integer")
.HasColumnName("guildconfigid");
b.Property<decimal>("GuildId")
.HasColumnType("numeric(20,0)")
.HasColumnName("guildid");
@ -748,10 +744,6 @@ namespace EllieBot.Migrations.PostgreSql
.HasColumnType("timestamp without time zone")
.HasColumnName("dateadded");
b.Property<int>("GuildConfigId")
.HasColumnType("integer")
.HasColumnName("guildconfigid");
b.Property<decimal>("GuildId")
.HasColumnType("numeric(20,0)")
.HasColumnName("guildid");
@ -933,10 +925,6 @@ namespace EllieBot.Migrations.PostgreSql
.HasColumnType("timestamp without time zone")
.HasColumnName("dateadded");
b.Property<int>("GuildConfigId")
.HasColumnType("integer")
.HasColumnName("guildconfigid");
b.Property<decimal>("GuildId")
.HasColumnType("numeric(20,0)")
.HasColumnName("guildid");
@ -1063,6 +1051,7 @@ namespace EllieBot.Migrations.PostgreSql
.HasColumnName("guildfilterconfigid");
b.Property<string>("Word")
.IsRequired()
.HasColumnType("text")
.HasColumnName("word");
@ -3364,10 +3353,6 @@ namespace EllieBot.Migrations.PostgreSql
.HasColumnType("timestamp without time zone")
.HasColumnName("dateadded");
b.Property<int>("GuildConfigId")
.HasColumnType("integer")
.HasColumnName("guildconfigid");
b.Property<decimal>("GuildId")
.HasColumnType("numeric(20,0)")
.HasColumnName("guildid");

View file

@ -0,0 +1,108 @@
BEGIN TRANSACTION;
CREATE TABLE "ef_temp_XpSettings" (
"Id" INTEGER NOT NULL CONSTRAINT "PK_XpSettings" PRIMARY KEY AUTOINCREMENT,
"DateAdded" TEXT NULL,
"GuildId" INTEGER NOT NULL,
"ServerExcluded" INTEGER NOT NULL
);
INSERT INTO "ef_temp_XpSettings" ("Id", "DateAdded", "GuildId", "ServerExcluded")
SELECT "Id", "DateAdded", "GuildId", "ServerExcluded"
FROM "XpSettings";
CREATE TABLE "ef_temp_FeedSub" (
"Id" INTEGER NOT NULL CONSTRAINT "PK_FeedSub" PRIMARY KEY AUTOINCREMENT,
"ChannelId" INTEGER NOT NULL,
"DateAdded" TEXT NULL,
"GuildId" INTEGER NOT NULL,
"Message" TEXT NULL,
"Url" TEXT NULL
);
INSERT INTO "ef_temp_FeedSub" ("Id", "ChannelId", "DateAdded", "GuildId", "Message", "Url")
SELECT "Id", "ChannelId", "DateAdded", "GuildId", "Message", "Url"
FROM "FeedSub";
CREATE TABLE "ef_temp_DelMsgOnCmdChannel" (
"Id" INTEGER NOT NULL CONSTRAINT "PK_DelMsgOnCmdChannel" PRIMARY KEY AUTOINCREMENT,
"ChannelId" INTEGER NOT NULL,
"DateAdded" TEXT NULL,
"GuildId" INTEGER NOT NULL,
"State" INTEGER NOT NULL
);
INSERT INTO "ef_temp_DelMsgOnCmdChannel" ("Id", "ChannelId", "DateAdded", "GuildId", "State")
SELECT "Id", "ChannelId", "DateAdded", "GuildId", "State"
FROM "DelMsgOnCmdChannel";
CREATE TABLE "ef_temp_AntiRaidSetting" (
"Id" INTEGER NOT NULL CONSTRAINT "PK_AntiRaidSetting" PRIMARY KEY AUTOINCREMENT,
"Action" INTEGER NOT NULL,
"DateAdded" TEXT NULL,
"GuildId" INTEGER NOT NULL,
"PunishDuration" INTEGER NOT NULL,
"Seconds" INTEGER NOT NULL,
"UserThreshold" INTEGER NOT NULL
);
INSERT INTO "ef_temp_AntiRaidSetting" ("Id", "Action", "DateAdded", "GuildId", "PunishDuration", "Seconds", "UserThreshold")
SELECT "Id", "Action", "DateAdded", "GuildId", "PunishDuration", "Seconds", "UserThreshold"
FROM "AntiRaidSetting";
CREATE TABLE "ef_temp_FilteredWord" (
"Id" INTEGER NOT NULL CONSTRAINT "PK_FilteredWord" PRIMARY KEY AUTOINCREMENT,
"DateAdded" TEXT NULL,
"GuildFilterConfigId" INTEGER NULL,
"Word" TEXT NOT NULL,
CONSTRAINT "FK_FilteredWord_GuildFilterConfig_GuildFilterConfigId" FOREIGN KEY ("GuildFilterConfigId") REFERENCES "GuildFilterConfig" ("Id")
);
INSERT INTO "ef_temp_FilteredWord" ("Id", "DateAdded", "GuildFilterConfigId", "Word")
SELECT "Id", "DateAdded", "GuildFilterConfigId", IFNULL("Word", '')
FROM "FilteredWord";
COMMIT;
PRAGMA foreign_keys = 0;
BEGIN TRANSACTION;
DROP TABLE "XpSettings";
ALTER TABLE "ef_temp_XpSettings" RENAME TO "XpSettings";
DROP TABLE "FeedSub";
ALTER TABLE "ef_temp_FeedSub" RENAME TO "FeedSub";
DROP TABLE "DelMsgOnCmdChannel";
ALTER TABLE "ef_temp_DelMsgOnCmdChannel" RENAME TO "DelMsgOnCmdChannel";
DROP TABLE "AntiRaidSetting";
ALTER TABLE "ef_temp_AntiRaidSetting" RENAME TO "AntiRaidSetting";
DROP TABLE "FilteredWord";
ALTER TABLE "ef_temp_FilteredWord" RENAME TO "FilteredWord";
COMMIT;
PRAGMA foreign_keys = 1;
BEGIN TRANSACTION;
CREATE UNIQUE INDEX "IX_XpSettings_GuildId" ON "XpSettings" ("GuildId");
CREATE UNIQUE INDEX "IX_FeedSub_GuildId_Url" ON "FeedSub" ("GuildId", "Url");
CREATE UNIQUE INDEX "IX_DelMsgOnCmdChannel_GuildId_ChannelId" ON "DelMsgOnCmdChannel" ("GuildId", "ChannelId");
CREATE UNIQUE INDEX "IX_AntiRaidSetting_GuildId" ON "AntiRaidSetting" ("GuildId");
CREATE INDEX "IX_FilteredWord_GuildFilterConfigId" ON "FilteredWord" ("GuildFilterConfigId");
COMMIT;
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20250202095042_fk-remove', '9.0.1');

View file

@ -11,7 +11,7 @@ using EllieBot.Db;
namespace EllieBot.Migrations.Sqlite
{
[DbContext(typeof(SqliteContext))]
[Migration("20250127062834_init")]
[Migration("20250202095107_init")]
partial class init
{
/// <inheritdoc />
@ -64,9 +64,6 @@ namespace EllieBot.Migrations.Sqlite
b.Property<DateTime?>("DateAdded")
.HasColumnType("TEXT");
b.Property<int>("GuildConfigId")
.HasColumnType("INTEGER");
b.Property<ulong>("GuildId")
.HasColumnType("INTEGER");
@ -562,9 +559,6 @@ namespace EllieBot.Migrations.Sqlite
b.Property<DateTime?>("DateAdded")
.HasColumnType("TEXT");
b.Property<int>("GuildConfigId")
.HasColumnType("INTEGER");
b.Property<ulong>("GuildId")
.HasColumnType("INTEGER");
@ -700,9 +694,6 @@ namespace EllieBot.Migrations.Sqlite
b.Property<DateTime?>("DateAdded")
.HasColumnType("TEXT");
b.Property<int>("GuildConfigId")
.HasColumnType("INTEGER");
b.Property<ulong>("GuildId")
.HasColumnType("INTEGER");
@ -796,6 +787,7 @@ namespace EllieBot.Migrations.Sqlite
.HasColumnType("INTEGER");
b.Property<string>("Word")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
@ -2505,9 +2497,6 @@ namespace EllieBot.Migrations.Sqlite
b.Property<DateTime?>("DateAdded")
.HasColumnType("TEXT");
b.Property<int>("GuildConfigId")
.HasColumnType("INTEGER");
b.Property<ulong>("GuildId")
.HasColumnType("INTEGER");

View file

@ -35,7 +35,6 @@ namespace EllieBot.Migrations.Sqlite
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false),
GuildId = table.Column<ulong>(type: "INTEGER", nullable: false),
UserThreshold = table.Column<int>(type: "INTEGER", nullable: false),
Seconds = table.Column<int>(type: "INTEGER", nullable: false),
@ -244,7 +243,6 @@ namespace EllieBot.Migrations.Sqlite
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false),
GuildId = table.Column<ulong>(type: "INTEGER", nullable: false),
ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false),
State = table.Column<bool>(type: "INTEGER", nullable: false),
@ -298,7 +296,6 @@ namespace EllieBot.Migrations.Sqlite
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false),
GuildId = table.Column<ulong>(type: "INTEGER", nullable: false),
ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false),
Url = table.Column<string>(type: "TEXT", nullable: true),
@ -1122,7 +1119,6 @@ namespace EllieBot.Migrations.Sqlite
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false),
GuildId = table.Column<ulong>(type: "INTEGER", nullable: false),
ServerExcluded = table.Column<bool>(type: "INTEGER", nullable: false),
DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true)
@ -1267,7 +1263,7 @@ namespace EllieBot.Migrations.Sqlite
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Word = table.Column<string>(type: "TEXT", nullable: true),
Word = table.Column<string>(type: "TEXT", nullable: false),
GuildFilterConfigId = table.Column<int>(type: "INTEGER", nullable: true),
DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true)
},

View file

@ -61,9 +61,6 @@ namespace EllieBot.Migrations.Sqlite
b.Property<DateTime?>("DateAdded")
.HasColumnType("TEXT");
b.Property<int>("GuildConfigId")
.HasColumnType("INTEGER");
b.Property<ulong>("GuildId")
.HasColumnType("INTEGER");
@ -559,9 +556,6 @@ namespace EllieBot.Migrations.Sqlite
b.Property<DateTime?>("DateAdded")
.HasColumnType("TEXT");
b.Property<int>("GuildConfigId")
.HasColumnType("INTEGER");
b.Property<ulong>("GuildId")
.HasColumnType("INTEGER");
@ -697,9 +691,6 @@ namespace EllieBot.Migrations.Sqlite
b.Property<DateTime?>("DateAdded")
.HasColumnType("TEXT");
b.Property<int>("GuildConfigId")
.HasColumnType("INTEGER");
b.Property<ulong>("GuildId")
.HasColumnType("INTEGER");
@ -793,6 +784,7 @@ namespace EllieBot.Migrations.Sqlite
.HasColumnType("INTEGER");
b.Property<string>("Word")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
@ -2502,9 +2494,6 @@ namespace EllieBot.Migrations.Sqlite
b.Property<DateTime?>("DateAdded")
.HasColumnType("TEXT");
b.Property<int>("GuildConfigId")
.HasColumnType("INTEGER");
b.Property<ulong>("GuildId")
.HasColumnType("INTEGER");

View file

@ -35,7 +35,6 @@ public class CommandHandler : IEService, IReadyExecutor, ICommandHandler
private readonly DbService _db;
private readonly BotConfig _bc;
// private readonly InteractionService _interactions;
public CommandHandler(
DiscordSocketClient client,
@ -44,7 +43,6 @@ public class CommandHandler : IEService, IReadyExecutor, ICommandHandler
BotConfigService bcs,
IBot bot,
IBehaviorHandler behaviorHandler,
// InteractionService interactions,
IServiceProvider services,
ShardData shardData)
{
@ -57,7 +55,6 @@ public class CommandHandler : IEService, IReadyExecutor, ICommandHandler
_db = db;
_services = services;
_shardData = shardData;
// _interactions = interactions;
}
public async Task OnReadyAsync()