0

I am working on a Django project with a MySQL backend. I'm curious about the best way to update a production server's database to reflect the changes made on the development server's database?

When I develop now, I make some changes to a models.py file, then to a schemamigration using South. Sometimes I do several migrations across several apps within the main project folder before it's ready for the production database. This means that there are several migration files in the app/migrations/ folder created by South.

So on the production server, how does one update the database to reflect all the changes made in development, without having any data loss?

Garfonzo
  • 499
  • 2
  • 18

1 Answers1

2

You need to creation migrations. South is probably most people's go to app in the Django world

http://south.aeracode.org/

Mike
  • 22,310
  • 7
  • 56
  • 79
  • I am using South, I mentioned it in my question. I'm not sure I understand what you're saying. – Garfonzo Nov 09 '12 at 06:34
  • once your migration files are in place just run `./manage.py migrate` you don't lose any data stored in the table. – Mike Nov 09 '12 at 14:56
  • Won't that be a problem if on the development server, I've run `./manage migrate` several times due to multiple DB changes but, running `./manage.py migrate` on the production server only picks up the latest migration, not all the migrations that happened along the way? I guess I'm worried about missing migrations in between the first and last migration that I do on the dev server. – Garfonzo Nov 09 '12 at 15:25
  • as long as all your migration files are in place it should pick them all up. – Mike Nov 09 '12 at 15:31
  • oh... wow, ok, and for sure they all go to the production server. Great thanks. – Garfonzo Nov 09 '12 at 15:32
  • if they don't.. you can also apply a migration per file if needed.. It's listed in the docs. So worse case just apply each migration file but it should pick them all up – Mike Nov 09 '12 at 15:37