Skip to content

Commit

Permalink
fix postgres 17 multidomain user
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Wojczal committed Oct 23, 2024
1 parent f0d5fc9 commit fd6d136
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions multidomain-tool/src/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,22 @@ public static function createPostgresUserAndDatabase($domain)
pg_prepare($dbconn_db, "", $query);
$result = pg_execute($dbconn_db, "", []);

$queries = [
"GRANT USAGE ON SCHEMA public TO {$username}",
"GRANT ALL ON ALL TABLES IN SCHEMA public TO {$username}",
"GRANT ALL ON ALL ROUTINES IN SCHEMA public TO {$username}",
"GRANT ALL ON ALL SEQUENCES IN SCHEMA public TO {$username}",
"ALTER DEFAULT PRIVILEGES FOR ROLE {$username} IN SCHEMA public GRANT ALL ON TABLES TO {$username}",
"ALTER DEFAULT PRIVILEGES FOR ROLE {$username} IN SCHEMA public GRANT ALL ON ROUTINES TO {$username}",
"ALTER DEFAULT PRIVILEGES FOR ROLE {$username} IN SCHEMA public GRANT ALL ON SEQUENCES TO {$username}",
];

foreach ($queries as $query) {
$query = "GRANT ALL ON SCHEMA public TO {$username}";
pg_prepare($dbconn_db, "", $query);
$result = pg_execute($dbconn_db, "", []);
}

if ($result) {
echo $color->ok("Postgres. GRANT ALL ON SCHEMA public granted to $username on database $username \n");
} else {
Expand Down

0 comments on commit fd6d136

Please sign in to comment.