From 4a42a4465c8ff5496229f8883b9d1532bf7c9cab Mon Sep 17 00:00:00 2001 From: GrailFinder Date: Sun, 7 Apr 2024 09:53:04 +0300 Subject: Feat: db connection and migrations --- cmd/start.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'cmd') diff --git a/cmd/start.go b/cmd/start.go index 00872aa..a1f051c 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -1,9 +1,10 @@ package cmd import ( - "os" "apjournal/config" + database "apjournal/internal/database/sql" "apjournal/internal/server" + "os" "log/slog" @@ -28,8 +29,11 @@ var startCmd = &cobra.Command{ "path", viper.ConfigFileUsed()) } cfg := config.LoadConfig(viper.GetViper()) - - srv := server.NewServer(cfg, log) + db, err := database.InitWithMigrate(cfg.DBURI, true) + if err != nil { + panic(err) + } + srv := server.NewServer(cfg, log, db.Conn) // listen for new messages log.Info("Listening for incoming events") srv.Listen() -- cgit v1.2.3