LoginSignup
0
1

More than 5 years have passed since last update.

docker-compose操作系コマンド

Posted at

長期間開発していないアプリをある日触り始めるとメモやCIに
自分が解決した課題の解決法が反映されていなかったり。。。
今回もその事象にはまったので以下に書いておきたい。

docker-compose

# container build (setting check
docker-compose build
# container start
docker-compose up

django migration

## Required docker-compose up
# sync model (make migrate script output to /migrations
docker-compose exec web python manage.py makemigration
# sync database
docker-compose exec web python manage.py migrate

その他、想定外事象対応
誤って手動でテーブル削除してmigrateエラーが出た場合
→/migrations以下のファイルを実際のテーブルと同じ状態にしてmigrate実行

修復不可能なぐらい差異ができてしまった
→/migrations以下のファイルを削除(「init.py」は除く)、かつ、djangoが利用しているDBの「django_migrations」テーブルをtruncateして、makemigrationを実施する

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1