aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dbstore/dbstore.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/dbstore/dbstore.go b/dbstore/dbstore.go
index d30d0a8..25c3564 100644
--- a/dbstore/dbstore.go
+++ b/dbstore/dbstore.go
@@ -56,13 +56,19 @@ func (me DbStore) isInitialized(ctx context.Context) (bool, error) {
return (version == initDbVersion), nil
}
+// enable foreign keys
+func (me DbStore) enableForeignKeys(ctx context.Context) error {
+ _, err := me.db.ExecContext(ctx, "PRAGMA foreign_keys = true;")
+ return err
+}
+
// initialize database
func (me DbStore) Init(ctx context.Context) error {
if inited, err := me.isInitialized(ctx); err != nil {
return err
} else if inited {
- // already initialized, return success
- return nil
+ // already initialized, enable foreign keys
+ return me.enableForeignKeys(ctx)
}
// read init query