From cf03e0e33859b213f1d7e55b300a074eea107100 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Wed, 1 Aug 2018 20:28:45 -0700 Subject: Create database package (refactoring) --- cli/cli.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'cli') diff --git a/cli/cli.go b/cli/cli.go index 4f5417c..f4014db 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -10,6 +10,7 @@ import ( "github.com/miniflux/miniflux/config" "github.com/miniflux/miniflux/daemon" + "github.com/miniflux/miniflux/database" "github.com/miniflux/miniflux/logger" "github.com/miniflux/miniflux/storage" "github.com/miniflux/miniflux/version" @@ -33,10 +34,13 @@ func Parse() { logger.EnableDebug() } - store := storage.NewStorage( - cfg.DatabaseURL(), - cfg.DatabaseMaxConnections(), - ) + db, err := database.NewConnectionPool(cfg.DatabaseURL(), cfg.DatabaseMinConns(), cfg.DatabaseMaxConns()) + if err != nil { + logger.Fatal("Unable to connect to the database: %v", err) + } + defer db.Close() + + store := storage.NewStorage(db) if *flagInfo { info() @@ -49,7 +53,7 @@ func Parse() { } if *flagMigrate { - store.Migrate() + database.Migrate(db) return } @@ -75,7 +79,7 @@ func Parse() { // Run migrations and start the deamon. if cfg.RunMigrations() { - store.Migrate() + database.Migrate(db) } // Create admin user and start the deamon. -- cgit v1.2.3