Reputation: 773
I am using ORM in ColdFusion 9 to create my database tables as necessary using
this.ormSettings.dbcreate = 'update'
I now need to add a new model and populate it with default data. But I only want to populate the entity if there is currently no data.
Can anyone point me in the right direction? I have tried to search for a resolution but am not having any luck. It is probably something simple but the solution currently escapes me.
Thanks.
Upvotes: 2
Views: 109
Reputation: 7519
Add something to onApplicationStart that fires off a process to check if data exists, and if not, add it.
I have done this in apps so I have data in the DB when I go to run tests.
Upvotes: 3
Reputation: 4118
There is a fairly easy way to do this if you set dbcreate = "dropcreate" via providing a SQL script: http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WS29fdb0a9aebd66bc9141f34123e5a0a3c9-8000.html
I doubt though you want to be doing dropcreate :)
So no easy solution. Either code something up possibly using onApplicationStart or just run the script in the db.
Upvotes: 3