Skip to content

Commit

Permalink
fix: 修复 PostgreSQL 创建数据库未修改所有者
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed Sep 26, 2023
1 parent c08fd0a commit 084f0a0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ func (c *Postgresql15Controller) AddDatabase(ctx http.Context) http.Response {

tools.Exec(`echo "CREATE DATABASE ` + database + `;" | su - postgres -c "psql"`)
tools.Exec(`echo "CREATE USER ` + user + ` WITH PASSWORD '` + password + `';" | su - postgres -c "psql"`)
tools.Exec(`echo "ALTER DATABASE ` + database + ` OWNER TO ` + user + `;" | su - postgres -c "psql"`)
tools.Exec(`echo "GRANT ALL PRIVILEGES ON DATABASE ` + database + ` TO ` + user + `;" | su - postgres -c "psql"`)

userConfig := "host " + database + " " + user + " 127.0.0.1/32 scram-sha-256"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ func (c *Postgresql16Controller) AddDatabase(ctx http.Context) http.Response {

tools.Exec(`echo "CREATE DATABASE ` + database + `;" | su - postgres -c "psql"`)
tools.Exec(`echo "CREATE USER ` + user + ` WITH PASSWORD '` + password + `';" | su - postgres -c "psql"`)
tools.Exec(`echo "ALTER DATABASE ` + database + ` OWNER TO ` + user + `;" | su - postgres -c "psql"`)
tools.Exec(`echo "GRANT ALL PRIVILEGES ON DATABASE ` + database + ` TO ` + user + `;" | su - postgres -c "psql"`)

userConfig := "host " + database + " " + user + " 127.0.0.1/32 scram-sha-256"
Expand Down

0 comments on commit 084f0a0

Please sign in to comment.