On Tue, 2007-11-09 at 22:50 -0300, Jorge Godoy wrote: > On Tuesday 11 September 2007 18:19:27 Halldór wrote: > > Hi there, > > > > I was just wondering. If I deploy my application and then find out > > that I did something wrong in my models. How do I update the database > > and ensure that I won't lose any data? > > > > Btw. I'm using SO. > > You can write update / downgrade SQL scripts with SO. There are recipes > around for that. I particularly prefer doing things to work just in one way, > so if I need to downgrade then this will be another upgrade. I store all my > update SQL scripts on the same repository as I store the project.
Depending on the database you are using, you might find a simple dump with full column names to be the easiest. If you write a little bash or perl script to do the job you could get it down in time to something negligable as far as public site interference goes. So it would: - lock out hits ( lots of ways of doing that, mod_rewrite can be used to make a user spin for a second ) - dump your table with full column names to an sql file - drop the table - run tg-admin sql create to make a new table - refill the table - unlock your blocker For that matter, if you know what the sql needs to be ( having run it on a dev machine say ), you don't even need to use tg-admin sql create, just make another sql file from your dev setup that will put in the new table. FWIW, for these sorts of tasks I'm finding I really like Perl. I don't like perl for big projects where I might have to decode my own illegible garbage, but it sure beats raw bash. HTH Iain --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears?hl=en -~----------~----~----~----~------~----~------~--~---

