qwat / QWAT

TEKSI Water module (project QWAT) - QGIS project
https://www.teksi.ch
GNU General Public License v2.0
58 stars 31 forks source link

Update delta files and bulk loading need a way to deactivate audit log triggers #248

Closed haubourg closed 6 years ago

haubourg commented 6 years ago

Applying migration logs all update inserts or delete triggered inside the delta files. Those should not be logged, they cause a massive DB growup and probably slow down a lot upgrade process too.
See https://github.com/qwat/qwat-data-model/issues/214#issuecomment-356876669

We need a small script to deactivate a/reactivate all logging triggers for deltas and bulk loading task. We need that in the sources, and referenced in the documentation.

Current workaround is to run the following query after the upgrade process:

DELETE FROM qwat_sys.logged_actions
 WHERE date(action_tstamp_tx)= date(now());
elemoine commented 6 years ago

Proposal:

Create qwat_sys.audit_tables and qwat_sys.unaudit_tables functions. The former would be responsible for calling qwat_sys.audit_table for all the tables to be audited. The latter would do the opposite.

Then we can call unaudit_tables in update/delta/pre-all.pyand audit_tables in update/delta/post-all.py, to disable auditing during migrations.

And we'd do likewise for views.

What do you think?

haubourg commented 6 years ago

Hey that sounds good and less hacky than playing with replica session variable. @3nids any thought?

elemoine commented 6 years ago

This is what I am proposing: https://github.com/qwat/qwat-data-model/compare/master...elemoine:ele_audit. I can turn this into a proper PR if people agree with the approach.

elemoine commented 6 years ago

This is the PR for this: https://github.com/qwat/qwat-data-model/pull/233.