From 3dd2ba4aa4309b589e809621de2ecee89ee54159 Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 4 Mar 2026 15:26:34 +0100 Subject: [PATCH] feat: register Vikunja tables with db package at init --- pkg/files/db.go | 4 ++++ pkg/models/models.go | 4 ++++ pkg/modules/migration/db.go | 6 ++++++ pkg/notifications/db.go | 6 ++++++ pkg/user/db.go | 6 ++++++ 5 files changed, 26 insertions(+) diff --git a/pkg/files/db.go b/pkg/files/db.go index e23167e1e..e602c90b5 100644 --- a/pkg/files/db.go +++ b/pkg/files/db.go @@ -35,6 +35,10 @@ func SetEngine() (err error) { return nil } +func init() { + db.RegisterTables(GetTables()) +} + // GetTables returns all structs which are also a table. func GetTables() []interface{} { return []interface{}{ diff --git a/pkg/models/models.go b/pkg/models/models.go index 17a30913a..906038138 100644 --- a/pkg/models/models.go +++ b/pkg/models/models.go @@ -36,6 +36,10 @@ var ( testUpdatedTime time.Time ) +func init() { + db.RegisterTables(GetTables()) +} + // GetTables returns all structs which are also a table. func GetTables() []interface{} { return []interface{}{ diff --git a/pkg/modules/migration/db.go b/pkg/modules/migration/db.go index e3940c1d7..20888abdd 100644 --- a/pkg/modules/migration/db.go +++ b/pkg/modules/migration/db.go @@ -16,6 +16,12 @@ package migration +import "code.vikunja.io/api/pkg/db" + +func init() { + db.RegisterTables(GetTables()) +} + // GetTables returns all structs which are also a table. func GetTables() []interface{} { return []interface{}{ diff --git a/pkg/notifications/db.go b/pkg/notifications/db.go index 385e05778..a7e01c1a5 100644 --- a/pkg/notifications/db.go +++ b/pkg/notifications/db.go @@ -16,6 +16,12 @@ package notifications +import "code.vikunja.io/api/pkg/db" + +func init() { + db.RegisterTables(GetTables()) +} + // GetTables returns all structs which are also a table. func GetTables() []interface{} { return []interface{}{ diff --git a/pkg/user/db.go b/pkg/user/db.go index 4d6b9b08a..8c9a2c4fc 100644 --- a/pkg/user/db.go +++ b/pkg/user/db.go @@ -16,6 +16,12 @@ package user +import "code.vikunja.io/api/pkg/db" + +func init() { + db.RegisterTables(GetTables()) +} + // GetTables returns all structs which are also a table. func GetTables() []interface{} { return []interface{}{