Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete all migration files in Django app

I'm trying to delete all migration files in my Django app using a single command. Here's the structure of my repository:

|-- core
|   |-- migrations
|       |-- __init__.py
|       |-- 0001_initial.py
|       |-- 0002_add_column1.py
|       |-- 0003_add_column1.py
|
|-- users
    |-- migrations
        |-- __init__.py
        |-- 0001_initial.py
        |-- 0002_add_column2.py

My goal is to delete all files besides __init__.py so the repo looks like this:

|-- core
|   |-- migrations
|       |-- __init__.py
|
|-- users
    |-- migrations
        |-- __init__.py

I've tried the following command but no luck:

find . -path "*/migrations/*.py" -not -name "__init__.py" -delete
like image 267
Johnny Metz Avatar asked Oct 23 '25 13:10

Johnny Metz


1 Answers

Try this, but change 'ROOT' to your root folder name:

find . -path "./ROOT/*/migrations/*.py" -not -name "__init__.py" -delete
like image 154
Elliot Avatar answered Oct 25 '25 04:10

Elliot