Make extensive use of raw string literals C#11 feature

This commit is contained in:
Kwoth
2023-01-21 01:12:11 +01:00
parent 0fe4f14d96
commit 63a9ae2dac
32 changed files with 756 additions and 587 deletions

View File

@@ -28,14 +28,16 @@ namespace NadekoBot.Migrations
table: "NsfwBlacklistedTags",
column: "GuildId");
migrationBuilder.Sql(@"INSERT INTO NsfwBlacklistedTags(Id, GuildId, Tag, DateAdded)
SELECT
Id,
(SELECT GuildId From GuildConfigs WHERE Id=GuildConfigId),
Tag,
DateAdded
FROM NsfwBlacklitedTag
WHERE GuildConfigId in (SELECT Id from GuildConfigs);");
migrationBuilder.Sql("""
INSERT INTO NsfwBlacklistedTags(Id, GuildId, Tag, DateAdded)
SELECT
Id,
(SELECT GuildId From GuildConfigs WHERE Id=GuildConfigId),
Tag,
DateAdded
FROM NsfwBlacklitedTag
WHERE GuildConfigId in (SELECT Id from GuildConfigs);
""");
migrationBuilder.DropTable(
name: "NsfwBlacklitedTag");

View File

@@ -50,24 +50,30 @@ namespace NadekoBot.Migrations
principalTable: "GuildConfigs",
principalColumn: "Id");
migrationBuilder.Sql(@"UPDATE Permissions
SET SecondaryTargetName='ACTUALEXPRESSIONS'
WHERE SecondaryTargetName='ActualCustomReactions' COLLATE NOCASE;");
migrationBuilder.Sql("""
UPDATE Permissions
SET SecondaryTargetName='ACTUALEXPRESSIONS'
WHERE SecondaryTargetName='ActualCustomReactions' COLLATE NOCASE;
""");
migrationBuilder.Sql(@"UPDATE Permissions
SET SecondaryTargetName='EXPRESSIONS'
WHERE SecondaryTargetName='CustomReactions' COLLATE NOCASE;");
migrationBuilder.Sql("""
UPDATE Permissions
SET SecondaryTargetName='EXPRESSIONS'
WHERE SecondaryTargetName='CustomReactions' COLLATE NOCASE;
""");
migrationBuilder.Sql(@"UPDATE Permissions
SET SecondaryTargetName= case lower(SecondaryTargetName)
WHEN 'editcustreact' THEN 'expredit'
WHEN 'delcustreact' THEN 'exprdel'
WHEN 'listcustreact' THEN 'exprlist'
WHEN 'addcustreact' THEN 'expradd'
WHEN 'showcustreact' THEN 'exprshow'
ELSE SecondaryTargetName
END
WHERE lower(SecondaryTargetName) in ('editcustreact', 'delcustreact', 'listcustreact', 'addcustreact', 'showcustreact');");
migrationBuilder.Sql("""
UPDATE Permissions
SET SecondaryTargetName= case lower(SecondaryTargetName)
WHEN 'editcustreact' THEN 'expredit'
WHEN 'delcustreact' THEN 'exprdel'
WHEN 'listcustreact' THEN 'exprlist'
WHEN 'addcustreact' THEN 'expradd'
WHEN 'showcustreact' THEN 'exprshow'
ELSE SecondaryTargetName
END
WHERE lower(SecondaryTargetName) in ('editcustreact', 'delcustreact', 'listcustreact', 'addcustreact', 'showcustreact');
""");
}
protected override void Down(MigrationBuilder migrationBuilder)

View File

@@ -42,13 +42,15 @@ namespace NadekoBot.Migrations
table: "FilterWordsChannelId",
column: "GuildConfigId");
migrationBuilder.Sql(@"INSERT INTO FilterWordsChannelId(Id, ChannelId, GuildConfigId, DateAdded)
SELECT Id, ChannelId, GuildConfigId1, DateAdded
FROM FilterChannelId
WHERE GuildConfigId1 is not null;
-- Remove them after moving them to a different table
DELETE FROM FilterChannelId
WHERE GuildConfigId is null;");
migrationBuilder.Sql("""
INSERT INTO FilterWordsChannelId(Id, ChannelId, GuildConfigId, DateAdded)
SELECT Id, ChannelId, GuildConfigId1, DateAdded
FROM FilterChannelId
WHERE GuildConfigId1 is not null;
-- Remove them after moving them to a different table
DELETE FROM FilterChannelId
WHERE GuildConfigId is null;
""");
migrationBuilder.DropColumn(
name: "GuildConfigId1",

View File

@@ -9,19 +9,21 @@ namespace NadekoBot.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(@"UPDATE Clubs
SET Name = Name || '#' || Discrim
WHERE Discrim <> 1;
UPDATE Clubs as co
SET Name =
CASE (select count(*) from Clubs as ci where co.Name == ci.Name) = 1
WHEN true
THEN Name
ELSE
Name || '#' || Discrim
END
WHERE Discrim = 1;");
migrationBuilder.Sql("""
UPDATE Clubs
SET Name = Name || '#' || Discrim
WHERE Discrim <> 1;
UPDATE Clubs as co
SET Name =
CASE (select count(*) from Clubs as ci where co.Name == ci.Name) = 1
WHEN true
THEN Name
ELSE
Name || '#' || Discrim
END
WHERE Discrim = 1;
""");
migrationBuilder.DropForeignKey(
name: "FK_Clubs_DiscordUser_OwnerId",