[][src]Function sql_audit::generate_audit

pub async fn generate_audit<'_>(
    pool: &'_ PgPool,
    exclude_tables: Vec<String>
) -> Result<()>

Generate the audit infrastructure for the database that the passed pool connects to. This function will:

  1. Create the sql_audit schema with audit table if the schema doesn't yet exist.
  2. Create the sql_audit_trigger function used in all generated TRIGGERs.
  3. Create triggers for all tables in the public schema which are not in exclude_tables.

Limitations

If you try to audit any table which does not have a pk column, the triggers will fail.

Errors

  1. Connection failure to the provided pool at any point will generate an error.
  2. Any normal Postgres errors (e.g. user doesn't have the right permissions)