mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
Make extensive use of raw string literals C#11 feature
This commit is contained in:
@@ -10,29 +10,35 @@ public static class MigrationQueries
|
||||
if (migrationBuilder.IsMySql())
|
||||
{
|
||||
migrationBuilder.Sql(
|
||||
@"INSERT IGNORE into reactionroles(guildid, channelid, messageid, emote, roleid, `group`, levelreq, dateadded)
|
||||
select guildid, channelid, messageid, emotename, roleid, exclusive, 0, reactionrolemessage.dateadded
|
||||
from reactionrole
|
||||
left join reactionrolemessage on reactionrolemessage.id = reactionrole.reactionrolemessageid
|
||||
left join guildconfigs on reactionrolemessage.guildconfigid = guildconfigs.id;");
|
||||
"""
|
||||
INSERT IGNORE into reactionroles(guildid, channelid, messageid, emote, roleid, `group`, levelreq, dateadded)
|
||||
select guildid, channelid, messageid, emotename, roleid, exclusive, 0, reactionrolemessage.dateadded
|
||||
from reactionrole
|
||||
left join reactionrolemessage on reactionrolemessage.id = reactionrole.reactionrolemessageid
|
||||
left join guildconfigs on reactionrolemessage.guildconfigid = guildconfigs.id;
|
||||
""");
|
||||
}
|
||||
else if (migrationBuilder.IsSqlite())
|
||||
{
|
||||
migrationBuilder.Sql(
|
||||
@"insert or ignore into reactionroles(guildid, channelid, messageid, emote, roleid, 'group', levelreq, dateadded)
|
||||
select guildid, channelid, messageid, emotename, roleid, exclusive, 0, reactionrolemessage.dateadded
|
||||
from reactionrole
|
||||
left join reactionrolemessage on reactionrolemessage.id = reactionrole.reactionrolemessageid
|
||||
left join guildconfigs on reactionrolemessage.guildconfigid = guildconfigs.id;");
|
||||
"""
|
||||
insert or ignore into reactionroles(guildid, channelid, messageid, emote, roleid, 'group', levelreq, dateadded)
|
||||
select guildid, channelid, messageid, emotename, roleid, exclusive, 0, reactionrolemessage.dateadded
|
||||
from reactionrole
|
||||
left join reactionrolemessage on reactionrolemessage.id = reactionrole.reactionrolemessageid
|
||||
left join guildconfigs on reactionrolemessage.guildconfigid = guildconfigs.id;
|
||||
""");
|
||||
}
|
||||
else if (migrationBuilder.IsNpgsql())
|
||||
{
|
||||
migrationBuilder.Sql(@"insert into reactionroles(guildid, channelid, messageid, emote, roleid, ""group"", levelreq, dateadded)
|
||||
select guildid, channelid, messageid, emotename, roleid, exclusive::int, 0, reactionrolemessage.dateadded
|
||||
from reactionrole
|
||||
left join reactionrolemessage on reactionrolemessage.id = reactionrole.reactionrolemessageid
|
||||
left join guildconfigs on reactionrolemessage.guildconfigid = guildconfigs.id
|
||||
ON CONFLICT DO NOTHING;");
|
||||
migrationBuilder.Sql("""
|
||||
insert into reactionroles(guildid, channelid, messageid, emote, roleid, "group", levelreq, dateadded)
|
||||
select guildid, channelid, messageid, emotename, roleid, exclusive::int, 0, reactionrolemessage.dateadded
|
||||
from reactionrole
|
||||
left join reactionrolemessage on reactionrolemessage.id = reactionrole.reactionrolemessageid
|
||||
left join guildconfigs on reactionrolemessage.guildconfigid = guildconfigs.id
|
||||
ON CONFLICT DO NOTHING;
|
||||
""");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -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");
|
||||
|
@@ -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)
|
||||
|
@@ -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",
|
||||
|
@@ -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",
|
||||
|
Reference in New Issue
Block a user