Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added db schema to postgres template #245

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/template/dbdriver/files/env/postgres.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ DB_PORT=5432
DB_DATABASE=blueprint
DB_USERNAME=melkey
DB_PASSWORD=password1234
DB_SCHEMA=public
3 changes: 2 additions & 1 deletion cmd/template/dbdriver/files/service/postgres.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var (
username = os.Getenv("DB_USERNAME")
port = os.Getenv("DB_PORT")
host = os.Getenv("DB_HOST")
schema = os.Getenv("DB_SCHEMA")
dbInstance *service
)

Expand All @@ -42,7 +43,7 @@ func New() Service {
if dbInstance != nil {
return dbInstance
}
connStr := fmt.Sprintf("postgres://%s:%s@%s:%s/%s?sslmode=disable", username, password, host, port, database)
connStr := fmt.Sprintf("postgres://%s:%s@%s:%s/%s?sslmode=disable&search_path=%s", username, password, host, port, database, schema)
db, err := sql.Open("pgx", connStr)
if err != nil {
log.Fatal(err)
Expand Down