Skip to content

Commit

Permalink
feat: add migration to set the pgAudit config
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
patheard committed May 7, 2024
1 parent 5c0ae89 commit 923ce30
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions migrations/versions/0449_pgaudit_config.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 923ce30

Please sign in to comment.