Any chance of something like this making it into the core?
It's a real pain at the moment. Using SQLObject gives you the illusion
of working in a nice object oriented way but once you populate with data
and then want to add/remove fields, the illusion is destroyed and it
creates a work flow issue.
You either put some code in to destroy and re-create the table +
re-populate with test data at start up time else you go and make the
changes to the tables directly and then they're out of sync with your
SQLObject definitions.
You can see how RoR ActiveRecord got around this by only reflecting the
database instead of trying to specify it - that's a different paradigm.
I know that SQLObject can work in this way although it's not very well
documented - doesn't look like a common path of usage.
I'm not sure how to progress with this once I'm using live data. Any
suggestions?
Hi,
There is no automated way to do this, because this is a hard thing to
do reliably.
It's just a lot of work (write a parser for SQL's CREATE+ALTER TABLE
statements, save old and table structure, generate ALTER TABLE
statements from the difference)
Fortunately, insane people like me have already done it. ;-)