Skip to content

Commit 57dc133

Browse files
authored
Add GRANT CREATE ON DATABASE TO (#81)
1 parent 7ad54f8 commit 57dc133

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/postgres/database.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const (
1616
GRANT_USAGE_SCHEMA = `GRANT USAGE ON SCHEMA "%s" TO "%s"`
1717
GRANT_ALL_TABLES = `GRANT %s ON ALL TABLES IN SCHEMA "%s" TO "%s"`
1818
DEFAULT_PRIVS_SCHEMA = `ALTER DEFAULT PRIVILEGES FOR ROLE "%s" IN SCHEMA "%s" GRANT %s ON TABLES TO "%s"`
19+
GRANT_CREATE_SCHEMA = `GRANT CREATE ON DATABASE "%s" TO "%s"`
1920
)
2021

2122
func (c *pg) CreateDB(dbname, role string) error {
@@ -31,6 +32,11 @@ func (c *pg) CreateDB(dbname, role string) error {
3132
if err != nil {
3233
return err
3334
}
35+
36+
_, err = c.db.Exec(fmt.Sprintf(GRANT_CREATE_SCHEMA, dbname, role))
37+
if err != nil {
38+
return err
39+
}
3440
return nil
3541
}
3642

0 commit comments

Comments
 (0)