You should think of migrations as a version control system for your database schema. makemigrations is responsible for packaging up your model changes into inpidual migration files - analogous to comexs - posepose pun.
The migration files for each app live in a “migrations” directory inside of that app, and are designed to be committed to, and distributed as part of, its codebase. You should be making them once on your andrunce opment the runce same migrations on your colleagues' machines, your staging machines, and eventually your production machines.
按照官方的說法,應該提交,並且在伺服器端應該直接執行
中文翻譯:migrate
,無需再次生成。建議提交到版本庫。
我目前是不同步到遠端庫的。
因為開發過程中要頻繁的對model進行修改,會產生很多migrations文件,不好控制migrate不出錯;
發布程序之前,首先確認是否進行model更新,如果有的話先進行makemigrations然後migrate,由於本地已經測試完成,所以不容易出現一些奇怪的同步問題。
為什麼不提交之前把migrations裡新生成的多次變動刪了 重新makemigrations一下然後提交版本庫呢
可是在本地,添加字段然後再刪除等等一些無用的操作,最後可能數據庫沒有任何變動,那麼這些 migrations 也得提交到伺服器上再運行一遍?