compute_ctl: run migrations to grant default grantable privileges (#6884)

## Problem

Following up on https://github.com/neondatabase/neon/pull/6845, we did
not make the default privileges grantable before, and therefore, even if
the users have full privileges, they are not able to grant them to
others.

Should be a final fix for
https://github.com/neondatabase/neon/issues/6236.

## Summary of changes

Add `WITH GRANT` to migrations so that neon_superuser can grant the
permissions.

---------

Signed-off-by: Alex Chi Z <chi@neon.tech>
This commit is contained in:
Alex Chi Z
2024-02-22 12:49:02 -05:00
committed by GitHub
parent 9c6145f0a9
commit 837988b6c9
2 changed files with 5 additions and 3 deletions

View File

@@ -778,8 +778,10 @@ END
$$;"#,
"GRANT pg_monitor TO neon_superuser WITH ADMIN OPTION",
// ensure tables created by superusers (i.e., when creating extensions) can be used by neon_superuser.
"ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO neon_superuser",
"ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO neon_superuser",
"ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO neon_superuser", // to-be removed in the future
"ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO neon_superuser", // to-be removed in the future
"ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO neon_superuser WITH GRANT OPTION",
"ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO neon_superuser WITH GRANT OPTION",
];
let mut query = "CREATE SCHEMA IF NOT EXISTS neon_migration";

View File

@@ -15,7 +15,7 @@ def test_migrations(neon_simple_env: NeonEnv):
endpoint.wait_for_migrations()
num_migrations = 6
num_migrations = 8
with endpoint.cursor() as cur:
cur.execute("SELECT id FROM neon_migration.migration_id")