mirror of
				https://gitlab.com/Kwoth/nadekobot.git
				synced 2025-11-03 16:24:27 -05:00 
			
		
		
		
	Fixed mysql and postgresql reactionrole migration, closes #370
This commit is contained in:
		@@ -1,10 +1,22 @@
 | 
				
			|||||||
using Microsoft.EntityFrameworkCore.Migrations;
 | 
					using Microsoft.EntityFrameworkCore;
 | 
				
			||||||
 | 
					using Microsoft.EntityFrameworkCore.Migrations;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace NadekoBot.Migrations;
 | 
					namespace NadekoBot.Migrations;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public static class MigrationQueries
 | 
					public static class MigrationQueries
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public static void MigrateRero(MigrationBuilder migrationBuilder)
 | 
					    public static void MigrateRero(MigrationBuilder migrationBuilder)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        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;");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else if (migrationBuilder.IsSqlite())
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            migrationBuilder.Sql(
 | 
					            migrationBuilder.Sql(
 | 
				
			||||||
                @"insert or ignore into reactionroles(guildid, channelid, messageid, emote, roleid, 'group', levelreq, dateadded)
 | 
					                @"insert or ignore into reactionroles(guildid, channelid, messageid, emote, roleid, 'group', levelreq, dateadded)
 | 
				
			||||||
@@ -13,4 +25,18 @@ from reactionrole
 | 
				
			|||||||
left join reactionrolemessage on reactionrolemessage.id = reactionrole.reactionrolemessageid
 | 
					left join reactionrolemessage on reactionrolemessage.id = reactionrole.reactionrolemessageid
 | 
				
			||||||
left join guildconfigs on reactionrolemessage.guildconfigid = guildconfigs.id;");
 | 
					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;");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            throw new NotSupportedException("This database provider doesn't have an implementation for MigrateRero");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user