Browse Source

feat(go): set pg schema on connect;

Vishal Dalwadi 6 months ago
parent
commit
fe0eefaf21
1 changed files with 1 additions and 7 deletions
  1. 1 7
      db/postgres.go

+ 1 - 7
db/postgres.go

@@ -17,7 +17,7 @@ type postgresConnector struct{}
 func (pg *postgresConnector) connect() (*gorm.DB, error) {
 	pgConf := servercfg.GetSQLConf()
 	dsn := fmt.Sprintf(
-		"host=%s port=%d user=%s password=%s dbname=%s sslmode=%s connect_timeout=5",
+		"host=%s port=%d user=%s password=%s dbname=%s sslmode=%s search_path=netmaker_v1 connect_timeout=5",
 		pgConf.Host,
 		pgConf.Port,
 		pgConf.Username,
@@ -39,11 +39,5 @@ func (pg *postgresConnector) connect() (*gorm.DB, error) {
 		return nil, err
 	}
 
-	// set the netmaker_v1 schema as the default schema.
-	err = db.Exec("SET search_path TO netmaker_v1").Error
-	if err != nil {
-		return nil, err
-	}
-
 	return db, nil
 }