Our grails app creates the normal tables for storing the domain objects.
For fraud and regulatory purposes, the key tables must be audited, i.e. every change should recorded along with who did it, and when.
On previous projects, we created a new audit schema, and put a copy of the normal tables into it, were each table was the same is the normal table except:
- 4 additional Columns: userId, IP, DataChanged, Action (Update, Delete, Insert)
- ID is no longer unique
- No constraints, no PK, no indexes.
- in an schema called audit.
On he prev. projects, the Oracle DB wrote a complex script to read the tables and columns from the normal schema, and create the corresponding tables/columns in the audit schema, then create the insert/update/delete triggers on the normal DBs tables.
We need to do something similar for MySQL.
WE need to do it at the DB (not code) level for security.
We are wondering if there is any way grails can help us with this. eg.
- Create a new grails audit project, copy (cut and paste) the domain classes, add the extra columns. This will auto-generate the schema at least. Then we will need to hand write the triggers, and put them in the BootStrap of the normal project.
- Use a grails script to read the table and column meta data from the main schema, and create the necessary sql statements to generate the audit schema, and generate the triggers on the normal schema tables.
- Dont use grails at all, write the entire script to create the audit tables and triggers outside of grails. Unfortunately, we dont have a DBA or SQL scripting guru available.
- use a plugin someone has already written to do this (Cant find any).
- something else?
Any ideas? Anyone else done something like this?