Here's what we do.  It's slightly tedious, but it generates a paper
trail (bit trail?) so I know when I updated what on which machine.

0. Make backups!

1. On my development machine, I make my changes to the database, and
copy the SQL statements into a file.  (Sometimes I use phpMyAdmin,
sometimes I write the SQL by hand, but it doesn't matter.)

2. I check in the SQL script from #1 to my SVN repository.

3. I ssh into the target server, update from SVN, and run an updater
shell script.  That shell script does two things: (a) runs the SQL
script from #2 against the DB; and (b) INSERTs the name of the script
into a special-purpose table, with a timestamp.  That table is
essentially a log of which update scripts have been run on that DB.

I don't do this stuff in SO/Python, mainly because there was no decent
"migration"-like package around, but also because I'm comfortable
enough with SQL and like to use a tool like phpMyAdmin to do some of
the SQL work for me.  This method also works for any database
whatsoever, even if it has nothing to do with a TG app.  I believe
there is an option you can give to "tg-admin sql create" etc. to have
it show you the SQL commands, so you could capture them and use the
rest of this recipe.  Having your DB changes under version control is
*really important*.

P.S. You can also use this method for updating data itself, in
addition to the DB schema... just check in the output from a mysqldump
or equivalent and use that.

-Ansel



On Sep 11, 2:19 pm, "Halldór" <[EMAIL PROTECTED]> 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.
>
> --
> kv. Halldór Rúnarsson


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to