feat: delete command messages with pk;msg -delete

This commit is contained in:
spiral
2021-09-26 22:49:43 -04:00
parent fa66fbe247
commit 0517c76abf
6 changed files with 48 additions and 11 deletions

View File

@@ -0,0 +1,8 @@
-- schema version 17: 2021-09-26 --
-- add channel_id to command message table
alter table command_messages add column channel_id bigint;
update command_messages set channel_id = 0;
alter table command_messages alter column channel_id set not null;
update info set schema_version = 17;

View File

@@ -6,9 +6,9 @@ namespace PluralKit.Core
{
public partial class ModelRepository
{
public Task SaveCommandMessage(IPKConnection conn, ulong messageId, ulong authorId) =>
conn.QueryAsync("insert into command_messages (message_id, author_id) values (@Message, @Author)",
new { Message = messageId, Author = authorId });
public Task SaveCommandMessage(IPKConnection conn, ulong messageId, ulong channelId, ulong authorId) =>
conn.QueryAsync("insert into command_messages (message_id, channel_id, author_id) values (@Message, @Channel, @Author)",
new { Message = messageId, Channel = channelId, Author = authorId });
public Task<CommandMessage?> GetCommandMessage(IPKConnection conn, ulong messageId) =>
conn.QuerySingleOrDefaultAsync<CommandMessage>("select * from command_messages where message_id = @Message",
@@ -23,5 +23,6 @@ namespace PluralKit.Core
{
public ulong AuthorId { get; set; }
public ulong MessageId { get; set; }
public ulong ChannelId { get; set; }
}
}

View File

@@ -12,7 +12,7 @@ namespace PluralKit.Core
internal class DatabaseMigrator
{
private const string RootPath = "PluralKit.Core.Database"; // "resource path" root for SQL files
private const int TargetSchemaVersion = 16;
private const int TargetSchemaVersion = 17;
private readonly ILogger _logger;
public DatabaseMigrator(ILogger logger)