From e4497377721cafb3b5e5ac711714585da931c564 Mon Sep 17 00:00:00 2001 From: Shubham Prajapati Date: Wed, 4 Sep 2024 15:08:11 +0530 Subject: [PATCH] "Moved two database initialization statements inside Init function" --- config/dbconfig/dbconfig.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/config/dbconfig/dbconfig.go b/config/dbconfig/dbconfig.go index afa415d..a707bc9 100644 --- a/config/dbconfig/dbconfig.go +++ b/config/dbconfig/dbconfig.go @@ -52,6 +52,10 @@ func GetDb() *gorm.DB { func Init() error { db := GetDb() + + // db.Exec(`ALTER TABLE leader_boards DROP COLUMN IF EXISTS users;`) + db.Exec(`CREATE EXTENSION IF NOT EXISTS "uuid-ossp";`) + if err := db.AutoMigrate( &migrate.User{}, &migrate.Role{}, @@ -79,9 +83,6 @@ func Init() error { log.Fatal(err) } - // db.Exec(`ALTER TABLE leader_boards DROP COLUMN IF EXISTS users;`) - db.Exec(`CREATE EXTENSION IF NOT EXISTS "uuid-ossp";`) - logwrapper.Log.Info("Congrats ! Automigration completed") return nil