posted under category: Free Code For You on August 13, 2006 by Nathan
If your shared development database server happens to have a permenant multiple drive failure like ours did on Friday, and if the project you're working on hadn't been added to the backups yet, and if you're smart enough to be using Reactor to manage your database abstraction and/or be your ORM service of choice, you just may be in luck!
One of the great things about Reactor is it creates metadata objects on all the tables it touches. The typical appliation for this feature is usually code generation, like scaffolding and such. Easy, cross-platform database information is really useful, especially in open-source software where you don't know what the target platform will be.
Now, the first thing you should do in a disaster situation like I described, as soon as you realize you're screwed, back up your reactor files, specifically those in the reactor projects file. In fact, just back up the whole reactor folder because those files are version-specific.
Next, change your reactor.xml file to be in production mode. Production mode will keep it from attempting to introspect your database. If it can't find the table, it will throw an error, so let's switch the mode. While you're in there, make sure you point to the correct dsn - if the existing server is still down, make a new DSN on an empty database and point the reactor.xml file to it.
Finally, you'll need to build a tool to loop through the tables Reactor knows about and write the create table scripts. Here, you can have mine (it works with sql server 2000 +. Feel free to modify it, then buy, sell or trade it for goods on the open market. It's better than gold, in a pinch. Just don't hold me accountable if anything bad happens.