mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-24 00:20:37 +00:00
## Problem fix https://github.com/neondatabase/neon/issues/6236 again ## Summary of changes This pull request adds a setup command in compute spec to modify default privileges of public schema to have full permission on table/sequence for neon_superuser. If an extension upgrades to superuser during creation, the tables/sequences they create in the public schema will be automatically granted to neon_superuser. Questions: * does it impose any security flaws? public schema should be fine... * for all extensions that create tables in schemas other than public, we will need to manually handle them (e.g., pg_anon). * we can modify some extensions to remove their superuser requirement in the future. * we may contribute to Postgres to allow for the creation of extensions with a specific user in the future. --------- Signed-off-by: Alex Chi Z <chi@neon.tech>
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
import time
|
|
|
|
from fixtures.neon_fixtures import NeonEnv
|
|
|
|
|
|
def test_migrations(neon_simple_env: NeonEnv):
|
|
env = neon_simple_env
|
|
env.neon_cli.create_branch("test_migrations", "empty")
|
|
|
|
endpoint = env.endpoints.create("test_migrations")
|
|
log_path = endpoint.endpoint_path() / "compute.log"
|
|
|
|
endpoint.respec(skip_pg_catalog_updates=False)
|
|
endpoint.start()
|
|
|
|
endpoint.wait_for_migrations()
|
|
|
|
num_migrations = 6
|
|
|
|
with endpoint.cursor() as cur:
|
|
cur.execute("SELECT id FROM neon_migration.migration_id")
|
|
migration_id = cur.fetchall()
|
|
assert migration_id[0][0] == num_migrations
|
|
|
|
with open(log_path, "r") as log_file:
|
|
logs = log_file.read()
|
|
assert f"INFO handle_migrations: Ran {num_migrations} migrations" in logs
|
|
|
|
endpoint.stop()
|
|
endpoint.start()
|
|
# We don't have a good way of knowing that the migrations code path finished executing
|
|
# in compute_ctl in the case that no migrations are being run
|
|
time.sleep(1)
|
|
with endpoint.cursor() as cur:
|
|
cur.execute("SELECT id FROM neon_migration.migration_id")
|
|
migration_id = cur.fetchall()
|
|
assert migration_id[0][0] == num_migrations
|
|
|
|
with open(log_path, "r") as log_file:
|
|
logs = log_file.read()
|
|
assert "INFO handle_migrations: Ran 0 migrations" in logs
|