From 07fb486f0d4afd69d8a0792a04ba11d343cb92fe Mon Sep 17 00:00:00 2001 From: DanPlayz0 Date: Fri, 14 Nov 2025 16:51:58 -0800 Subject: [PATCH] fix: update MessageId and ChannelId fields to be nullable --- panels.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/panels.go b/panels.go index 1c27df6..2a814c8 100644 --- a/panels.go +++ b/panels.go @@ -12,8 +12,8 @@ import ( // ALTER TABLE panels ADD COLUMN use_threads bool NOT NULL DEFAULT false; type Panel struct { PanelId int `json:"panel_id"` - MessageId uint64 `json:"message_id,string"` - ChannelId uint64 `json:"channel_id,string"` + MessageId *uint64 `json:"message_id,string"` + ChannelId *uint64 `json:"channel_id,string"` GuildId uint64 `json:"guild_id,string"` Title string `json:"title"` Content string `json:"content"` @@ -59,8 +59,8 @@ func (p PanelTable) Schema() string { return ` CREATE TABLE IF NOT EXISTS panels( "panel_id" SERIAL NOT NULL UNIQUE, - "message_id" int8 NOT NULL UNIQUE, - "channel_id" int8 NOT NULL, + "message_id" int8 DEFAULT NULL UNIQUE, + "channel_id" int8 DEFAULT NULL, "guild_id" int8 NOT NULL, "title" varchar(255) NOT NULL, "content" text NOT NULL, @@ -728,7 +728,7 @@ UPDATE panels return err } -func (p *PanelTable) UpdateMessageId(ctx context.Context, panelId int, messageId uint64) (err error) { +func (p *PanelTable) UpdateMessageId(ctx context.Context, panelId int, messageId *uint64) (err error) { query := ` UPDATE panels SET "message_id" = $1 @@ -739,6 +739,17 @@ WHERE "panel_id" = $2; return } +func (p *PanelTable) UpdateChannelId(ctx context.Context, panelId int, channelId *uint64) (err error) { + query := ` +UPDATE panels +SET "channel_id" = $1 +WHERE "panel_id" = $2; +` + + _, err = p.Exec(ctx, query, channelId, panelId) + return +} + func (p *PanelTable) EnableAll(ctx context.Context, guildId uint64) (err error) { query := ` UPDATE panels