Skip to content

Commit 21ba7f4

Browse files
committed
add ddl for removing audit triggers
1 parent 6a8b29c commit 21ba7f4

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/db_audit.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,14 @@
6666
CREATE TRIGGER tr_auditoria_are
6767
AFTER INSERT OR UPDATE OR DELETE ON avaliacao_registros_execucao
6868
FOR EACH ROW EXECUTE FUNCTION auditoria.fn_auditoria();
69+
"""
70+
71+
REMOVE_AUDIT_TRIGGERS = """
72+
DROP TRIGGER IF EXISTS tr_auditoria_pt ON plano_trabalho;
73+
DROP TRIGGER IF EXISTS tr_auditoria_pe ON plano_entregas;
74+
DROP TRIGGER IF EXISTS tr_auditoria_part ON participante;
75+
DROP TRIGGER IF EXISTS tr_auditoria_us ON users;
76+
DROP TRIGGER IF EXISTS tr_auditoria_co ON contribuicao;
77+
DROP TRIGGER IF EXISTS tr_auditoria_en ON entrega;
78+
DROP TRIGGER IF EXISTS tr_auditoria_are ON avaliacao_registros_execucao;
6979
"""

src/db_config.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from sqlalchemy.orm import DeclarativeBase
99
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
1010
from sqlalchemy.sql import text
11-
from db_audit import AUDIT_DDL
11+
from db_audit import AUDIT_DDL, REMOVE_AUDIT_TRIGGERS
1212

1313
SQLALCHEMY_DATABASE_URL = os.environ["SQLALCHEMY_DATABASE_URL"]
1414

@@ -35,6 +35,11 @@ async def create_audit_ddl():
3535
async with engine.begin() as conn:
3636
await conn.execute(text(AUDIT_DDL))
3737

38+
async def remove_audit_triggers():
39+
40+
async with engine.begin() as conn:
41+
await conn.execute(text(REMOVE_AUDIT_TRIGGERS))
42+
3843

3944
async def get_async_session() -> AsyncGenerator[AsyncSession, None]:
4045
"""Retorna a sessão do banco de dados.

0 commit comments

Comments
 (0)