Commit 2e92c9bc authored by Micaël Bergeron's avatar Micaël Bergeron

add default privileges to schema creation

parent f13409e3
......@@ -155,11 +155,14 @@ def ensure_schema_exists(db_conn, schema_name):
:schema: database schema
"""
cursor = db_conn.cursor()
schema_identifier = psycopg2.sql.Identifier(schema_name)
create_schema = psycopg2.sql.SQL("CREATE SCHEMA IF NOT EXISTS {}").format(schema_identifier)
grant_schema = psycopg2.sql.SQL("ALTER DEFAULT PRIVILEGES IN SCHEMA {} GRANT SELECT ON TABLES TO readonly").format(schema_identifier)
create_schema = psycopg2.sql.SQL("CREATE SCHEMA IF NOT EXISTS {0}").format(
psycopg2.sql.Identifier(schema_name)
)
cursor.execute(create_schema)
cursor.execute(grant_schema)
db_conn.commit()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment