From 923ce30f7fa5893ad80d8724071e7737ee00717f Mon Sep 17 00:00:00 2001 From: Pat Heard Date: Tue, 7 May 2024 16:28:18 -0400 Subject: [PATCH] feat: add migration to set the pgAudit config Add migration to disable pgAudit on the app_db_user and rdsproxyadmin user. This is being done to save costs and reduce the logging pressure on the database instances. --- migrations/versions/0449_pgaudit_config.py | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 migrations/versions/0449_pgaudit_config.py diff --git a/migrations/versions/0449_pgaudit_config.py b/migrations/versions/0449_pgaudit_config.py new file mode 100644 index 0000000000..324ac2d456 --- /dev/null +++ b/migrations/versions/0449_pgaudit_config.py @@ -0,0 +1,24 @@ +""" + +Revision ID: 0449_set_pgaudit_config +Revises: 0448_update_verify_code2 +Create Date: 2024-05-07 16:30:00 + +""" +from alembic import op + +revision = "0449_set_pgaudit_config" +down_revision = "0448_update_verify_code2" + +roles = ["app_db_user", "rdsproxyadmin"] +database_name = op.get_bind().engine.url.database # database name that the migration is being run on + + +def upgrade(): + for role in roles: + op.execute(f"ALTER ROLE {role} IN DATABASE {database_name} SET pgaudit.log TO 'NONE'") + + +def downgrade(): + for role in roles: + op.execute(f"ALTER ROLE {role} IN DATABASE {database_name} RESET pgaudit.log")