Open cristiam86 opened 1 month ago
@cristiam86 any more information you can give me on this ticket?
Schema:
Use the new database
files for all of this => https://github.com/yeagerai/genlayer-simulator/blob/main/database/functions.py
Inserts will happen to the audit table when:
call_contract_function
send_transaction
deploy_intelligent_contract
After looking into the following two options:
transactions_audit
table
I have decided to go for the transactions_audit
table for the following options:
postgresql.conf
file, triggers are a different matter) by command (pgaudit.log = 'write'
)transactions_audit
table offers a more fine grained approachtransaction_audit
table(*)
-- Create a function to log changes
CREATE OR REPLACE FUNCTION log_transaction_changes() RETURNS TRIGGER AS $$
BEGIN
IF TG_OP = 'INSERT' OR TG_OP = 'UPDATE' THEN
PERFORM pgaudit.audit_function('WRITE');
END IF;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
-- Create a trigger on the transactions table
CREATE TRIGGER audit_transaction_changes
AFTER INSERT OR UPDATE ON transactions
FOR EACH ROW EXECUTE FUNCTION log_transaction_changes();
New table called "rollup"/"audit" with all the transaction states.