aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
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
}