Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create pg2ili_abwasser per default #540

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
4 changes: 3 additions & 1 deletion datamodel/12_1_roles.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ GRANT ALL ON ALL TABLES IN SCHEMA tww_cfg TO tww_user;
ALTER DEFAULT PRIVILEGES IN SCHEMA tww_od GRANT ALL ON TABLES TO tww_user;
ALTER DEFAULT PRIVILEGES IN SCHEMA tww_od GRANT ALL ON SEQUENCES TO tww_user;

DO $$ BEGIN EXECUTE 'GRANT CREATE ON DATABASE ' || (SELECT current_database()) || ' TO "tww_user"'; END $$; -- required for ili2pg imports/exports
GRANT ALL ON SCHEMA pg2ili_abwasser TO tww_user;
ALTER DEFAULT PRIVILEGES IN SCHEMA pg2ili_abwasser GRANT ALL ON TABLES TO tww_user;
ALTER DEFAULT PRIVILEGES IN SCHEMA pg2ili_abwasser GRANT ALL ON SEQUENCES TO tww_user;

/* Manager */
GRANT ALL ON SCHEMA tww_vl TO tww_manager;
Expand Down
1 change: 1 addition & 0 deletions datamodel/changelogs/0001/01_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ CREATE SCHEMA tww_sys;
CREATE SCHEMA tww_vl;
CREATE SCHEMA tww_od;
CREATE SCHEMA tww_cfg;
CREATE SCHEMA pg2ili_abwasser;
7 changes: 5 additions & 2 deletions datamodel/test/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

TWW_SCHEMAS = ("tww_sys", "tww_vl", "tww_od", "tww_cfg", "tww_app")
PG_SCHEMAS = ("pg_toast", "information_schema", "pg_catalog", "public")
ILI_SCHEMAS = ("pg2ili_abwasser",)


class TestSchemas(unittest.TestCase, DbTestBase):
Expand All @@ -23,7 +24,7 @@ def setUpClass(cls):
cls.conn = psycopg.connect(f"service={pgservice}")

def test_list_schemas(self):
schemas = ", ".join([f"'{schema}'" for schema in TWW_SCHEMAS + PG_SCHEMAS])
schemas = ", ".join([f"'{schema}'" for schema in TWW_SCHEMAS + PG_SCHEMAS + ILI_SCHEMAS])
list_schemas = f"SELECT schema_name FROM information_schema.schemata WHERE schema_name NOT IN ({schemas});"
self.check_empty(list_schemas)

Expand All @@ -32,7 +33,9 @@ def test_app_schema(self):
self.check_empty(list_tables)

def test_data_schemas(self):
pg_schemas = ", ".join([f"'{schema}'" for schema in TWW_SCHEMAS + PG_SCHEMAS])
pg_schemas = ", ".join(
[f"'{schema}'" for schema in TWW_SCHEMAS + PG_SCHEMAS + ILI_SCHEMAS]
)
list_views = (
"SELECT * FROM information_schema.tables WHERE table_type = 'VIEW' "
f"AND table_schema NOT IN ('tww_app', {pg_schemas})"
Expand Down