0

I have a little unusual migration to do in my django website:

I need to restore a database with older configurations, because the old website is still working and i need it's data.

When i finish the restore process, how will i migrate it? Can i run an older migration again and make the new ones later? Or the django migrations system can recognize the current database configuration and propose new migrations?

It may be a simple migration (or not), but i have to be sure of what i am doing before.

Sorry for my bad english.I appreciate any help.

  • Was the old database also created with django and simply resembles an earlier state with some newer migrations missing? – Tim Apr 03 '16 at 20:02
  • Yes, the database is used in the old website with an earlier state. It's the same django project, actually. But the older is also with an older version of code. – Roberto Assunção Filho Apr 03 '16 at 20:11
  • Then you should be able to simply migrate the database with the migrations you created. The state of the migrations is stored in the database, so that will be restored with the rest of the data. Test it in a test environment first though, to be sure not to loose any data. – Tim Apr 03 '16 at 20:12
  • Ok, doing it now. Thanks. – Roberto Assunção Filho Apr 03 '16 at 20:14

1 Answers1

-1

You can go through process :

1.First of all create a new database with namesay-> NewProduction.

  1. Now delete all migrations files from apps you want to delete.
  2. Run python manage.py showmigrations to see which all migrations have been there but not migrated.
  3. Start running migrate command starting from auth, sites, session and then your apps one by one.
  4. Take dump of your previous database, but table wise .. take a dump of the table once at a time of which you are sure and push it to NewProduction.
  5. This above step will keep your django_content_type, django_sessions, etc table unaltered.
  6. Change all the content_type_values in the updated table, look into djang_content_type table for each app and update accordingly.

this is the proper solution I did for my project migrations.

dilwaria
  • 33
  • 8