aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/database/connection.go')
-rw-r--r--pkg/database/connection.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/pkg/database/connection.go b/pkg/database/connection.go
index 18fa2e6..06514df 100644
--- a/pkg/database/connection.go
+++ b/pkg/database/connection.go
@@ -21,9 +21,16 @@ var (
func CreateSchema() error {
if !tableExists("messages") {
- err := DBCon.CreateTable((*models.Message)(nil), &orm.CreateTableOptions{
- IfNotExists: true,
- })
+ for _, model := range []interface{}{(*models.Message)(nil),
+ (*models.MessageToReferences)(nil)} {
+
+ err := DBCon.CreateTable(model, &orm.CreateTableOptions{
+ IfNotExists: true,
+ })
+ if err != nil {
+ return err
+ }
+ }
// Add tsvector column for subjects
DBCon.Exec("ALTER TABLE messages ADD COLUMN tsv_subject tsvector;")
@@ -33,7 +40,7 @@ func CreateSchema() error {
DBCon.Exec("ALTER TABLE messages ADD COLUMN tsv_body tsvector;")
DBCon.Exec("CREATE INDEX body_idx ON messages USING gin(tsv_body);")
- return err
+ return nil
}
return nil
}