Toad World® Forums

Automatically Generating "CRUD" layers.


#1

For all of our tables, we add audit columns with triggers that maintain dates and user info for creation and edit operatoins. we spent too much time doing this for new development and I would like to automate adding the columns (and the trigger) to each entity in a physical model.

I’m fairly handy with vbScript, but i’m struggling quite a bit sorting out how to really get started in extending TDM to do something like this…

If someone could help me get started that would be a HUGE kick-start for my effort.

here is an example of what i want to do

DB:MySQL5

From a logical model when doing the conversion (or separately as a macro), extend the scripting section for mysql5 entity to add two columns for ‘date_created’ and ‘date_modified’ with a date datatype. and then create two simple triggers for each entity…

Can someone help shell out a wireframe of this? I don’t need it to be done for me, but i just need to see the way!

Thanks,

Eric


#2

Hello Eric,

Please find attached a script that my co-worker Mario has made for you.
Run the script in Scripting Window (Tools menu, Expert Mode enabled).

Please check it out if it meets your requirements. Thanks.

Note on line:
var Model = app.Models.GetObject(0);
//The parameter in GetObject determines here with which model the script should work.
//0 is the first model listed in the Application View.
//1 is the second model listed in the Application View
//etc.

Regards,

Vladka + Mario
script_Eric.zip (678 Bytes)