Williams
Williams

Reputation: 4328

Django 1.7 synchronize unmigrated apps

I started my model:

myapp.models.py

class MyModel(models.Model):

    field_a = models.FloatField()
    field_c = models.FloatField()

Then ran ./manage.py migrate on my new project and it was all good:

Operations to perform:
  Synchronize unmigrated apps: myapp
  Apply all migrations: admin, contenttypes, auth, sessions
Synchronizing apps without migrations:
  Creating tables...
    Creating table myapp_mymodel
  Installing custom SQL...
  Installing indexes...
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying sessions.0001_initial... OK

Then I changed my model:

class MyModel(models.Model):

    field_a = models.FloatField()
    field_b = models.FloatField()
    field_c = models.FloatField()

I ran ./manage.py migrate again and nothing happened.

(project)$ ./manage.py migrate 
Operations to perform:
  Synchronize unmigrated apps: myapp
  Apply all migrations: admin, contenttypes, auth, sessions
Synchronizing apps without migrations:
  Creating tables...
  Installing custom SQL...
  Installing indexes...
Running migrations:
  No migrations to apply.

I'm wondering what I need to do to make my new app migrate?

Upvotes: 7

Views: 6325

Answers (2)

Dipesh Mittal
Dipesh Mittal

Reputation: 119

If this had been happening even if you had run the makemigrations command, you need to check if the __initial__.py empty file is present in the migrations folder. I had an incidence once when I had created migrations by running on a testing remote server and even though I had copied all created migrations to my code, I had forgotten to copy the placeholder empty file that helps the migrate command identify apps that have migrations to run.

Hope it helps someone.

Upvotes: 4

Williams
Williams

Reputation: 4328

Ack, answered my own question.

What I needed to do was run:

./manage.py makemigrations myapp

Upvotes: 14

Related Questions