From f2fae82ace46f6529fe1cec767dfe55b5da7c2fa Mon Sep 17 00:00:00 2001 From: Vaniog Date: Thu, 6 Jun 2024 20:40:57 +0300 Subject: [PATCH] sqlite support --- app/config/config.go | 19 +++++++++++++++++++ app/goto_model.go | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/config/config.go b/app/config/config.go index 4a19e50..f0e210a 100644 --- a/app/config/config.go +++ b/app/config/config.go @@ -31,6 +31,9 @@ func init() { if err := loadMySQL(); err == nil { return } + if err := loadSqlite(); err == nil { + return + } } func loadSource() { @@ -95,3 +98,19 @@ func loadPostgres() error { ) return nil } + +func loadSqlite() error { + var sqlite struct { + Database string `envconfig:"DB" required:"true"` + } + + if err := envconfig.Process("SQLITE", &sqlite); err != nil { + return err + } + + URL = fmt.Sprintf( + "sqlite://%s", + sqlite.Database, + ) + return nil +} diff --git a/app/goto_model.go b/app/goto_model.go index c7a4100..5ac0818 100644 --- a/app/goto_model.go +++ b/app/goto_model.go @@ -88,7 +88,7 @@ func (gm gotoModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { func (gm gotoModel) View() string { return lipgloss.JoinVertical( 0, - "Migration name or version\n", + "Goto (migration name or version)\n", gm.migration.View(), "\n", gm.help.View(gm.keymap),