Merge pull request #37 from DarkKirb/fix-foreign-key-error

Fix the foreign key error for real
This commit is contained in:
Charlotte 🦝 Delenk 2022-11-25 08:18:28 +01:00 committed by GitHub
commit 46e47e40ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,3 +1,43 @@
diff --git a/database/portal.go b/database/portal.go
index d8ce90d..7c2d431 100644
--- a/database/portal.go
+++ b/database/portal.go
@@ -150,13 +150,13 @@ func (p *Portal) Scan(row dbutil.Scannable) *Portal {
func (p *Portal) Insert() {
query := `
- INSERT INTO portal (dcid, receiver, type, other_user_id, dc_guild_id, dc_parent_id, mxid,
+ INSERT INTO portal (dcid, receiver, type, other_user_id, dc_guild_id, mxid,
plain_name, name, name_set, topic, topic_set, avatar, avatar_url, avatar_set,
encrypted, in_space, first_event_id)
- VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18)
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)
`
_, err := p.db.Exec(query, p.Key.ChannelID, p.Key.Receiver, p.Type,
- strPtr(p.OtherUserID), strPtr(p.GuildID), strPtr(p.ParentID), strPtr(string(p.MXID)),
+ strPtr(p.OtherUserID), strPtr(p.GuildID), strPtr(string(p.MXID)),
p.PlainName, p.Name, p.NameSet, p.Topic, p.TopicSet, p.Avatar, p.AvatarURL.String(), p.AvatarSet,
p.Encrypted, p.InSpace, p.FirstEventID.String())
@@ -169,13 +169,13 @@ func (p *Portal) Insert() {
func (p *Portal) Update() {
query := `
UPDATE portal
- SET type=$1, other_user_id=$2, dc_guild_id=$3, dc_parent_id=$4, mxid=$5,
- plain_name=$6, name=$7, name_set=$8, topic=$9, topic_set=$10, avatar=$11, avatar_url=$12, avatar_set=$13,
- encrypted=$14, in_space=$15, first_event_id=$16
- WHERE dcid=$17 AND receiver=$18
+ SET type=$1, other_user_id=$2, dc_guild_id=$3, mxid=$4,
+ plain_name=$5, name=$6, name_set=$7, topic=$8, topic_set=$9, avatar=$10, avatar_url=$11, avatar_set=$12,
+ encrypted=$13, in_space=$14, first_event_id=$15
+ WHERE dcid=$16 AND receiver=$17
`
_, err := p.db.Exec(query,
- p.Type, strPtr(p.OtherUserID), strPtr(p.GuildID), strPtr(p.ParentID), strPtr(string(p.MXID)),
+ p.Type, strPtr(p.OtherUserID), strPtr(p.GuildID), strPtr(string(p.MXID)),
p.PlainName, p.Name, p.NameSet, p.Topic, p.TopicSet, p.Avatar, p.AvatarURL.String(), p.AvatarSet,
p.Encrypted, p.InSpace, p.FirstEventID.String(),
p.Key.ChannelID, p.Key.Receiver)
diff --git a/portal.go b/portal.go
index 25e0dc2..e305942 100644
--- a/portal.go