0

showmigrations shows that there is 31 available migrations:

# python3 manage.py showmigrations
admin
 [X] 0001_initial
 [X] 0002_auto_20190114_1409
 [X] 0003_auto_20190114_1410
auth
 [X] 0001_initial
 [X] 0002_alter_permission_name_max_length
 [X] 0003_alter_user_email_max_length
 [X] 0004_alter_user_username_opts
 [X] 0005_alter_user_last_login_null
 [X] 0006_require_contenttypes_0002
 [X] 0007_auto_20190114_1409
authtoken
 [X] 0001_initial
 [X] 0002_auto_20160226_1747
 [X] 0003_auto_20190114_1409
contenttypes
 [X] 0001_initial
 [X] 0002_remove_content_type_name
 [X] 0003_auto_20190114_1409
exchange_delivery
 [X] 0001_initial
 [X] 0002_enlarge_phone_field
 [X] 0003_unique_external_id
 [X] 0004_add_warehouse
 [X] 0005_add_delivery_point_type
 [X] 0006_update_delivery_type_operating_mode
 [X] 0007_add_delivery_point_region_model
 [X] 0008_update_warehouse_exchange
 [X] 0009_add_verbose_name_for_warehouse_and_add_delivery_point_banned_group
 [X] 0010_add_active_flag_to_warehouse
 [X] 0011_auto_20190114_1409
sessions
 [X] 0001_initial
 [X] 0002_auto_20190114_1410
volt
 [X] 0001_initial
 [X] 0002_auto_20190114_1410

How to apply all this migrations ? migrate shows that No migrations to apply

# python3 manage.py migrate
Operations to perform:
  Synchronize unmigrated apps: corsheaders, export, opinion, volt.integration1c.delivery, custom_logger, event_listener, legacy, region, order, catalog, promo_table, messages, staticfiles, api, best_product, shop, general, market_cpa, rest_framework, delivery, exchange, talk
  Apply all migrations: auth, authtoken, sessions, exchange_delivery, admin, volt, contenttypes
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
  Installing custom SQL...
/usr/lib/python3.6/site-packages/django/core/management/commands/loaddata.py:239: RemovedInDjango19Warning: initial_data fixtures are deprecated. Use data migrations instead.
  RemovedInDjango19Warning

Installed 0 object(s) (of 6) from 1 fixture(s)
Running migrations:
  No migrations to apply.

I'm not familiar with Django, I need just dockerize existing app.

As far as I understand from output of python3 manage.py syncdb command

django.db.utils.ProgrammingError: (1146, "Table '220-django.auth_user' doesn't exist")

Problem is that initial migrations for django and django-admin are not applied

Project is under Django 1.8.14

3
  • Try using python3 manage.py migrate app_name for the base app. Replace app_name with your base app. Jan 14, 2019 at 11:35
  • try this answer
    – Alex K.
    Jan 14, 2019 at 11:41
  • @Sam, how to define base app ? I have 5 top level apps in INSTALLED_APPS at general/settings.py Jan 14, 2019 at 11:51

2 Answers 2

2

As I can see, all the migrations has [X] beside their names. Means these migrations are already applied, as per documentation. If there is any un-applied migrations, then it will show up as [ ] beside the name of the migration. For more details(if the migrations has been applied or not), please check the django_migrations table in DB.

6
  • Is it possible that [X] is result of fake migration and showmigrations migrations are not applied in fact? I added strange output of python3 manage.py syncdb to question Jan 14, 2019 at 11:32
  • Yes, if you fake apply a migration, it will show [X] as there has been an entry made in django_migrations table.
    – ruddra
    Jan 14, 2019 at 11:34
  • I don't know why you want to use syncdb. its depricated and just replicates python manage.py migrate. I think you can look into this repo regarding dockerizing django: github.com/ruddra/docker-django
    – ruddra
    Jan 14, 2019 at 12:35
  • Thank you for link to repo! I checked database 220-django on production, it has following tables paste.ubuntu.com/p/zDSfjPC44G Could you please tell me, is it standart Django tables ? Jan 14, 2019 at 14:34
  • Yes. They are standard table for a django project with default apps.
    – ruddra
    Jan 14, 2019 at 16:52
0

You have some entries in django_migrations table in your database so that migrate shows No migrations to apply. To solve this, goto database console and run the following command

delete from django_migrations;

Or, directly go to the database table and delete all rows.

Then run

python manage.py migrate

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.