2

I've just upgraded my project to Django 1.8.4. I've never used migrations in this project before. I discovered that I had to explicitly run the "makemigrations" command against four of my apps since they contained foreign keys to the auth_user table. Do I need to run the makemigrations command against my other six applications? The reason I ask is because the documents say,

If your app already has models and database tables, and doesn’t have migrations yet (for example, you created it against a previous Django version), you’ll need to convert it to use migrations"

However, when I ran the command against my "home" app, I received this message:

No changes detected in app 'home'

When converting a project to Django 1.8, should you run the makemigrations command against all of your apps and then run "migrate --fake-initial" if the actual database tables already exist?

Thanks.

Jim
  • 13,430
  • 26
  • 104
  • 155
  • I have updated my answer after suffering for a lot of hours ... It is essential to migrate all the applications **simultaneously** if django cannot do it with the relevant command. – raratiru May 07 '16 at 17:55

1 Answers1

6

Update: Make sure that the migrations folder contains an __init__.py.


Indeed, there are many times, I have to delete and recreate my development database.

During this procedure, I have encountered the same issue especially after upgrading to Django 1.8.* / 1.9.*.

In my script, after deleting the contents of my migrations folders, I am running makemigrations in all my applications separately simultaneously.

./manage.py makemigrations <myapp1> <myapp2> ... <myappN>

Before that, I backup all my data:

./manage.py dumpdata --exclude auth.permission --exclude contenttypes --exclude admin.LogEntry --indent 2 > db.json
raratiru
  • 8,748
  • 4
  • 73
  • 113
  • I'm afraid of migrations. Specifically, I'm afraid I'll get into a situation in which migrations won't run and I won't be able to update the migration files so they will. If I ever reach that point, can I assume I'll be able to do as you described and delete all the migration files in my "migrations" directories, run "makemigrations" on each app, and essentially start over? Thanks. – Jim Sep 22 '15 at 21:52
  • @Robert Sometimes migrations make me feel that their complicated structure will leave me hanging in front of a situation I am unable to cope with. Some other times, they leave me speechless of their capabilities which saved me from destroying the database. At the bottom line -however- all that counts, are the data. I really enjoy, deleting the database and restoring it automatically, just to avoid the fuss of debugging migrations. Somewhere there lies the secret that makes our relationship balanced. I have updated my answer! – raratiru Sep 22 '15 at 22:11