mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-04 19:17:37 +08:00
fix foreign key constraints
This commit is contained in:
parent
8da043f012
commit
1de1deb059
@ -19,7 +19,7 @@ type StoredMessageAttribute struct {
|
|||||||
ID int64 // ID is the crc64 of 字段s below
|
ID int64 // ID is the crc64 of 字段s below
|
||||||
MessageSeq int32
|
MessageSeq int32
|
||||||
InternalID int32
|
InternalID int32
|
||||||
SenderUin int64
|
SenderUin int64 // SenderUin is fk to UinInfo
|
||||||
Timestamp int64
|
Timestamp int64
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ type StoredGuildMessageAttribute struct {
|
|||||||
ID int64 // ID is the crc64 of 字段s below
|
ID int64 // ID is the crc64 of 字段s below
|
||||||
MessageSeq int64
|
MessageSeq int64
|
||||||
InternalID int64
|
InternalID int64
|
||||||
SenderTinyID int64
|
SenderTinyID int64 // SenderTinyID is fk to TinyInfo
|
||||||
Timestamp int64
|
Timestamp int64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,26 +61,46 @@ func (s *database) Open() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "create sqlite3 table error")
|
return errors.Wrap(err, "create sqlite3 table error")
|
||||||
}
|
}
|
||||||
|
err = s.db.Insert(Sqlite3UinInfoTableName, &UinInfo{Name: "null"})
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "insert into sqlite3 table "+Sqlite3UinInfoTableName+" error")
|
||||||
|
}
|
||||||
err = s.db.Create(Sqlite3TinyInfoTableName, &TinyInfo{})
|
err = s.db.Create(Sqlite3TinyInfoTableName, &TinyInfo{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "create sqlite3 table error")
|
return errors.Wrap(err, "create sqlite3 table error")
|
||||||
}
|
}
|
||||||
|
err = s.db.Insert(Sqlite3TinyInfoTableName, &TinyInfo{Name: "null"})
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "insert into sqlite3 table "+Sqlite3TinyInfoTableName+" error")
|
||||||
|
}
|
||||||
err = s.db.Create(Sqlite3MessageAttributeTableName, &StoredMessageAttribute{},
|
err = s.db.Create(Sqlite3MessageAttributeTableName, &StoredMessageAttribute{},
|
||||||
"FOREIGN KEY(SenderUin) REFERENCES "+Sqlite3UinInfoTableName+"(Uin)",
|
"FOREIGN KEY(SenderUin) REFERENCES "+Sqlite3UinInfoTableName+"(Uin)",
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "create sqlite3 table error")
|
return errors.Wrap(err, "create sqlite3 table error")
|
||||||
}
|
}
|
||||||
|
err = s.db.Insert(Sqlite3MessageAttributeTableName, &StoredMessageAttribute{})
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "insert into sqlite3 table "+Sqlite3MessageAttributeTableName+" error")
|
||||||
|
}
|
||||||
err = s.db.Create(Sqlite3GuildMessageAttributeTableName, &StoredGuildMessageAttribute{},
|
err = s.db.Create(Sqlite3GuildMessageAttributeTableName, &StoredGuildMessageAttribute{},
|
||||||
"FOREIGN KEY(SenderTinyID) REFERENCES "+Sqlite3TinyInfoTableName+"(ID)",
|
"FOREIGN KEY(SenderTinyID) REFERENCES "+Sqlite3TinyInfoTableName+"(ID)",
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "create sqlite3 table error")
|
return errors.Wrap(err, "create sqlite3 table error")
|
||||||
}
|
}
|
||||||
|
err = s.db.Insert(Sqlite3GuildMessageAttributeTableName, &StoredGuildMessageAttribute{})
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "insert into sqlite3 table "+Sqlite3GuildMessageAttributeTableName+" error")
|
||||||
|
}
|
||||||
err = s.db.Create(Sqlite3QuotedInfoTableName, &QuotedInfo{})
|
err = s.db.Create(Sqlite3QuotedInfoTableName, &QuotedInfo{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "create sqlite3 table error")
|
return errors.Wrap(err, "create sqlite3 table error")
|
||||||
}
|
}
|
||||||
|
err = s.db.Insert(Sqlite3QuotedInfoTableName, &QuotedInfo{QuotedContent: "null"})
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "insert into sqlite3 table "+Sqlite3QuotedInfoTableName+" error")
|
||||||
|
}
|
||||||
err = s.db.Create(Sqlite3GroupMessageTableName, &StoredGroupMessage{},
|
err = s.db.Create(Sqlite3GroupMessageTableName, &StoredGroupMessage{},
|
||||||
"FOREIGN KEY(AttributeID) REFERENCES "+Sqlite3MessageAttributeTableName+"(ID)",
|
"FOREIGN KEY(AttributeID) REFERENCES "+Sqlite3MessageAttributeTableName+"(ID)",
|
||||||
"FOREIGN KEY(QuotedInfoID) REFERENCES "+Sqlite3QuotedInfoTableName+"(ID)",
|
"FOREIGN KEY(QuotedInfoID) REFERENCES "+Sqlite3QuotedInfoTableName+"(ID)",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user