From eeec866a31a06efe94357e61f28f896263465a47 Mon Sep 17 00:00:00 2001 From: "Benjamin A. Shelton" Date: Wed, 7 Oct 2026 18:57:26 -0600 Subject: [PATCH] Commit WIP. Laptop charger isn't charging? --- go.mod | 2 ++ go.sum | 7 +++++++ internal/app/migration.go | 17 +++++++++++++++++ internal/models/db.go | 5 +++++ internal/settings/settings.go | 7 ++++--- 5 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 internal/app/migration.go diff --git a/go.mod b/go.mod index 865cbc5..66429f3 100644 --- a/go.mod +++ b/go.mod @@ -14,6 +14,7 @@ require ( github.com/go-telegram/bot v1.25.0 // indirect github.com/grbit/go-json v0.11.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jmoiron/sqlx v1.3.4 // indirect github.com/joho/godotenv v1.5.1 // indirect github.com/klauspost/compress v1.19.1 // indirect github.com/klauspost/cpuid/v2 v2.2.9 // indirect @@ -32,6 +33,7 @@ require ( github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect go.destrealm.net/cwrap v0.0.0-20201109183439-2847b5bcef78 // indirect go.destrealm.net/errors v1.4.1 // indirect + go.destrealm.net/migratory v0.0.0-20261007163818-ce33bd6231af // indirect go.destrealm.net/vfs v0.0.0-20261005172258-d049b9777092 // indirect golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect golang.org/x/sys v0.47.0 // indirect diff --git a/go.sum b/go.sum index a459e31..ddd7091 100644 --- a/go.sum +++ b/go.sum @@ -16,18 +16,23 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fsnotify/fsnotify v1.10.1 h1:b0/UzAf9yR5rhf3RPm9gf3ehBPpf0oZKIjtpKrx59Ho= github.com/fsnotify/fsnotify v1.10.1/go.mod h1:TLheqan6HD6GBK6PrDWyDPBaEV8LspOxvPSjC+bVfgo= +github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-telegram/bot v1.25.0 h1:C072msZtr+GjJiQsX/UJLirz+jzSNZVWkckxWufR7Ww= github.com/go-telegram/bot v1.25.0/go.mod h1:i2TRs7fXWIeaceF3z7KzsMt/he0TwkVC680mvdTFYeM= github.com/grbit/go-json v0.11.0 h1:bAbyMdYrYl/OjYsSqLH99N2DyQ291mHy726Mx+sYrnc= github.com/grbit/go-json v0.11.0/go.mod h1:IYpHsdybQ386+6g3VE6AXQ3uTGa5mquBme5/ZWmtzek= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jmoiron/sqlx v1.3.4 h1:wv+0IJZfL5z0uZoUjlpKgHkgaFSYD+r9CfrXjEXsO7w= +github.com/jmoiron/sqlx v1.3.4/go.mod h1:2BljVx/86SuTyjE+aPYlHCTNvZrnJXghYGpNiXLBMCQ= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/klauspost/compress v1.19.1 h1:VsB4HPswih7mmZ8WleSFQ75c/Ui1M4trX5oAsJnhSlk= github.com/klauspost/compress v1.19.1/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ= github.com/klauspost/cpuid/v2 v2.2.9 h1:66ze0taIn2H33fBvCkXuv9BmCwDfafmiIVpKV9kKGuY= github.com/klauspost/cpuid/v2 v2.2.9/go.mod h1:rqkxqrZ1EhYM9G+hXH7YdowN5R5RGN6NK4QwQ3WMXF8= +github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-sqlite3 v1.14.52 h1:wVbm2Qnf4OXkqhBTSPuCRZDRnxfbVrrmiCEroVdog8U= github.com/mattn/go-sqlite3 v1.14.52/go.mod h1:6JTjA44L93a0QCyJef5YvlPoKXntQPjzWv5gtm9sB6w= github.com/mymmrac/telego v1.12.1 h1:yx1T5pPSNsU3BjLR7jnfY0D4dtL9caH58Y9e8uzjR88= @@ -67,6 +72,8 @@ go.destrealm.net/cwrap v0.0.0-20201109183439-2847b5bcef78 h1:6PhjBZRPMK4g2svJSw5 go.destrealm.net/cwrap v0.0.0-20201109183439-2847b5bcef78/go.mod h1:XEMURlSRl36Iik3A1iigcziH/GIsfNZdWauoHMGf8YI= go.destrealm.net/errors v1.4.1 h1:1qbZuBKK4AMAHV2fSoTJTzKJH5w7WQlHK1Q8AEsJ7/U= go.destrealm.net/errors v1.4.1/go.mod h1:XTWkMcoJuLkH2i3eTHPlotnEE11ce8L0Bf8CtbPFzAI= +go.destrealm.net/migratory v0.0.0-20261007163818-ce33bd6231af h1:gSSUyNEMpJxo8N5QMg3neDvzlp6d/TMz0tVWiICFYQs= +go.destrealm.net/migratory v0.0.0-20261007163818-ce33bd6231af/go.mod h1:MeZ29G/OcVD2F8k+D9PfPaD57f0RlXFxsvGITnv9vEs= go.destrealm.net/vfs v0.0.0-20261005172258-d049b9777092 h1:eKEE+/czReOg8R7VjLwx+V/IdeLb1x1lHzEoWH5SRwg= go.destrealm.net/vfs v0.0.0-20261005172258-d049b9777092/go.mod h1:Ii64o7M71chtLhSllUZ+Yw5Oh7p9LZ3XaBghuXRmy6Y= golang.org/x/arch v0.0.0-20210923205945-b76863e36670 h1:18EFjUmQOcUvxNYSkA6jO9VAiXCnxFY6NyDX0bHDmkU= diff --git a/internal/app/migration.go b/internal/app/migration.go new file mode 100644 index 0000000..5bc572e --- /dev/null +++ b/internal/app/migration.go @@ -0,0 +1,17 @@ +package app + +import ( + "code.destrealm.net/zancarius/justusbot/internal/settings" + "go.destrealm.net/migratory" +) + +func DoMigration(conf *settings.Settings) error { + mg, err := migratory.New(conf.System.DSN) + if err != nil { + return err + } + + _ = mg + + return nil +} diff --git a/internal/models/db.go b/internal/models/db.go index 601dbaf..f5d4ef0 100644 --- a/internal/models/db.go +++ b/internal/models/db.go @@ -9,6 +9,11 @@ import ( func connect(conf *settings.Settings) error { db, err := sql.Open("sqlite3", conf.System.DSN) + if err != nil { + return nil + } + + _ = db return nil } diff --git a/internal/settings/settings.go b/internal/settings/settings.go index a4f1f69..e92eb00 100644 --- a/internal/settings/settings.go +++ b/internal/settings/settings.go @@ -15,7 +15,7 @@ import ( type Settings struct { file string `toml:"-"` - fs vfs.VFS `toml:"-"` + FS vfs.VFS `toml:"-"` API *API `toml:"api"` DailyScripture *DailyScripture `toml:"daily_scripture"` Translations *Translations `toml:"translations"` @@ -26,7 +26,7 @@ type Settings struct { // Reload previously loaded configuration. func (s *Settings) Reload() error { - st, err := LoadSettings(s.file, s.fs) + st, err := LoadSettings(s.file, s.FS) if err != nil { return err } @@ -46,7 +46,7 @@ func (s *Settings) Save() error { if err != nil { return err } - fp, err := s.fs.Mutable().OpenFile(s.file, os.O_TRUNC|os.O_CREATE, 0644) + fp, err := s.FS.Mutable().OpenFile(s.file, os.O_TRUNC|os.O_CREATE, 0644) if err != nil { return err } @@ -70,6 +70,7 @@ type DailyScripture struct { type System struct { TimeZone string `toml:"timezone"` + DSN string `toml:"dsn"` } type Service struct {