aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Magorsch <arzano@gentoo.org>2020-06-22 00:45:14 +0000
committerMax Magorsch <arzano@gentoo.org>2020-06-22 00:45:14 +0000
commit2149bb7fb6b6f732ac8364e45d072a22921957db (patch)
treeb72b5b876489df7cbec280b06440b89f9fe46a2d /pkg/database
parentImprove the error handling during the import (diff)
downloadarchives-2149bb7fb6b6f732ac8364e45d072a22921957db.tar.gz
archives-2149bb7fb6b6f732ac8364e45d072a22921957db.tar.bz2
archives-2149bb7fb6b6f732ac8364e45d072a22921957db.zip
Rework the data model to improve the performance
Signed-off-by: Max Magorsch <arzano@gentoo.org>
Diffstat (limited to 'pkg/database')
-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
}