If you don't need the history of the app migrations then it is pretty straightforward, you will basically end up with a squashed migration. If you do need the migration history (there is another system that is not up to sync with yours, etc) you are stuck, and I would suggest you start using a version control system (git, hg, etc) Assuming it is ok to end up with one squashed migration:
1) Remove any changes you have made in your code that inform the database schema for the app(s) in question(so model changes) 2) Access the database directly (assuming postgres - psql, other databases have different interfaces) 3) There is a table django_migrations with the fields id, app, name, applied. Run a delete from django_migrations where app = ''; for whatever app you deleted the migrations from (run it a few times if you deleted multiple app migrations) 4) For all the apps you need to rebuild migrations for ./manage makemigrations [app-names] 5)For each app that you needed to rebuild the migrations ./mange migrate [app-name] --fake This tells the database to write to the dajngo_migrations table that the migration was run, but doesn't actually change the schema. This is why your code and db need to be in sync. Otherwise you will have changes in the migration that are not reflected in the db, but the migtration is marked as having been run You are now back in shape. Now set up git. I am happy to help or point you to references for it Kirby On Wednesday, June 6, 2018 at 8:54:48 AM UTC-4, Leif wrote: > > Dear Django Experts: > > Somehow I deleted the files under migrations directory. Now I am no longer > able to migrate new changes. I got 'No change detected' message when I > apply python manage.py migrate. Anway I can restore files under migrations > directory? > > Best, > > Leif > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3709a8fc-5666-4ae8-9a9c-4b9b85bd89c4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.