Skip to content

Commit 07fb486

Browse files
committed
fix: update MessageId and ChannelId fields to be nullable
1 parent d6f4363 commit 07fb486

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

panels.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212
// ALTER TABLE panels ADD COLUMN use_threads bool NOT NULL DEFAULT false;
1313
type Panel struct {
1414
PanelId int `json:"panel_id"`
15-
MessageId uint64 `json:"message_id,string"`
16-
ChannelId uint64 `json:"channel_id,string"`
15+
MessageId *uint64 `json:"message_id,string"`
16+
ChannelId *uint64 `json:"channel_id,string"`
1717
GuildId uint64 `json:"guild_id,string"`
1818
Title string `json:"title"`
1919
Content string `json:"content"`
@@ -59,8 +59,8 @@ func (p PanelTable) Schema() string {
5959
return `
6060
CREATE TABLE IF NOT EXISTS panels(
6161
"panel_id" SERIAL NOT NULL UNIQUE,
62-
"message_id" int8 NOT NULL UNIQUE,
63-
"channel_id" int8 NOT NULL,
62+
"message_id" int8 DEFAULT NULL UNIQUE,
63+
"channel_id" int8 DEFAULT NULL,
6464
"guild_id" int8 NOT NULL,
6565
"title" varchar(255) NOT NULL,
6666
"content" text NOT NULL,
@@ -728,7 +728,7 @@ UPDATE panels
728728
return err
729729
}
730730

731-
func (p *PanelTable) UpdateMessageId(ctx context.Context, panelId int, messageId uint64) (err error) {
731+
func (p *PanelTable) UpdateMessageId(ctx context.Context, panelId int, messageId *uint64) (err error) {
732732
query := `
733733
UPDATE panels
734734
SET "message_id" = $1
@@ -739,6 +739,17 @@ WHERE "panel_id" = $2;
739739
return
740740
}
741741

742+
func (p *PanelTable) UpdateChannelId(ctx context.Context, panelId int, channelId *uint64) (err error) {
743+
query := `
744+
UPDATE panels
745+
SET "channel_id" = $1
746+
WHERE "panel_id" = $2;
747+
`
748+
749+
_, err = p.Exec(ctx, query, channelId, panelId)
750+
return
751+
}
752+
742753
func (p *PanelTable) EnableAll(ctx context.Context, guildId uint64) (err error) {
743754
query := `
744755
UPDATE panels

0 commit comments

Comments
 (0)