diff options
author | Frédéric Guillot <fred@miniflux.net> | 2018-08-01 20:28:45 -0700 |
---|---|---|
committer | Frédéric Guillot <fred@miniflux.net> | 2018-08-01 20:28:45 -0700 |
commit | cf03e0e33859b213f1d7e55b300a074eea107100 (patch) | |
tree | 3b88987c42c75b946c4e4b8eeb71fa2359bfe79d /cli | |
parent | 17054b396eff571f49812074024cb9db2e098bdc (diff) |
Create database package (refactoring)
Diffstat (limited to 'cli')
-rw-r--r-- | cli/cli.go | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -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. |