aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Magorsch <arzano@gentoo.org>2020-06-24 22:19:16 +0000
committerMax Magorsch <arzano@gentoo.org>2020-06-24 22:19:16 +0000
commit37b5a95f01acb573dd6698c2df9104b9c1f5d084 (patch)
treed654072ed64e37b7e4c198f9de4641e09f36f368 /pkg/database/connection.go
parentAdd an option to recompute the thread references (diff)
downloadarchives-37b5a95f01acb573dd6698c2df9104b9c1f5d084.tar.gz
archives-37b5a95f01acb573dd6698c2df9104b9c1f5d084.tar.bz2
archives-37b5a95f01acb573dd6698c2df9104b9c1f5d084.zip
Create message_to_reference table if not present
Signed-off-by: Max Magorsch <arzano@gentoo.org>
Diffstat (limited to 'pkg/database/connection.go')
-rw-r--r--pkg/database/connection.go31
1 files changed, 22 insertions, 9 deletions
diff --git a/pkg/database/connection.go b/pkg/database/connection.go
index 4f7353c..aa26d5f 100644
--- a/pkg/database/connection.go
+++ b/pkg/database/connection.go
@@ -19,17 +19,17 @@ var (
// CreateSchema creates the tables in the database
// in case they don't alreay exist
func CreateSchema() error {
- if !tableExists("messages") {
- for _, model := range []interface{}{(*models.Message)(nil),
- (*models.MessageToReferences)(nil)} {
+ //
+ // Message
+ //
+ if !tableExists("messages") {
- err := DBCon.CreateTable(model, &orm.CreateTableOptions{
- IfNotExists: true,
- })
- if err != nil {
- return err
- }
+ err := DBCon.CreateTable((*models.Message)(nil), &orm.CreateTableOptions{
+ IfNotExists: true,
+ })
+ if err != nil {
+ return err
}
// Add tsvector column for subjects
@@ -42,6 +42,19 @@ func CreateSchema() error {
return nil
}
+
+ //
+ // MessageToReference
+ //
+ if !tableExists("message_to_references") {
+ err := DBCon.CreateTable((*models.MessageToReferences)(nil), &orm.CreateTableOptions{
+ IfNotExists: true,
+ })
+ if err != nil {
+ return err
+ }
+ }
+
return nil
}