No migrations to apply 発生

 

1) PyCharm から migrate を実行すると No migrations to apply が発生する。

 

No migrations to apply.
Your models in app(s): 'account' have changes that are not yet reflected
in a migration, and so won't be applied.

 

2) Macのターミナルから showmigrations を実行してみた。

 python manage.py showmigrations

 

raise ImproperlyConfigured("settings.DATABASES is improperly configured. "
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly
configured. Please supply the ENGINE value. Check settings documentation for more
details.

 

ということで、DB設定が不適切ということで怒られました。

 settings.DATABASES is improperly configured. Please supply the ENGINE value.

 

settings.py(本件ではsettings_common.py)でDBの設定は下記のとおり。手詰まり。

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'private_diary',
'USER': os.environ.get('DB_USER'),
'PASSWORD': os.environ.get('DB_PASSWORD'),
'HOST': 'localhost',
'PORT': '',
}
}

 

3) エラーメッセージの指示に従って、makemigrations をPyCharm で実行してみる。 

OKが出たが、書籍の内容とは異なる。 (0001, 0002 が終わって 0003まで進んだってこと?)

/Users/y50xave/venv_private_diary/bin/python
/Users/y50xave/venv_private_diary/private_diary/manage.py makemigrations
Migrations for 'account':
/Users/y50xave/venv_private_diary/lib/python3.8/site-packages/allauth/account/
migrations/0003_auto_20211107_0118.py
- Alter field id on emailaddress
- Alter field id on emailconfirmation

Process finished with exit code 0

 

/Users/y50xave/venv_private_diary/bin/python /Users/y50xave/venv_private_diary/
private_diary/manage.py migrate
Operations to perform:
Apply all migrations: account, accounts, admin, auth, contenttypes, sessions, sites
Running migrations:
Applying account.0003_auto_20211107_0118... OK

Process finished with exit code 0

 

正常性確認ってどうすればよいのだろう。

 

4) DB

エラーが出ているのだから DBには反映されていない??

 

private_diary=# \dt;
List of relations
Schema | Name | Type | Owner
--------+--------------------------------------+-------+---------
public | account_emailaddress | table | y50xave
public | account_emailconfirmation | table | y50xave
public | accounts_customuser | table | y50xave
public | accounts_customuser_groups | table | y50xave
public | accounts_customuser_user_permissions | table | y50xave
public | auth_group | table | y50xave
public | auth_group_permissions | table | y50xave
public | auth_permission | table | y50xave
public | django_admin_log | table | y50xave
public | django_content_type | table | y50xave
public | django_migrations | table | y50xave
public | django_session | table | y50xave
public | django_site | table | y50xave
(13 rows)

private_diary=# select * from django_migrations
private_diary-# select * from django_admin_log
private_diary-# select * from django_session