본문 바로가기

메타인지/TIL

TIL 09/09

 migrations 리셋하는법

1. Remove the all migrations files within your project

Go through each of your projects apps migration folder and remove everything inside, except the __init__.py file.

Or if you are using a unix-like OS you can run the following script (inside your project dir):

find . -path "*/migrations/*.py" -not -name "__init__.py" -delete
find . -path
"*/migrations/*.pyc"  -delete

2. Drop the current database, or delete the db.sqlite3 if it is your case.

3. Create the initial migrations and generate the database schema:

python manage.py makemigrations
python manage.py migrate

And you are good to go.

 

출처: <https://simpleisbetterthancomplex.com/tutorial/2016/07/26/how-to-reset-migrations.html>

 

 

'메타인지 > TIL' 카테고리의 다른 글

TIL 09/11  (0) 2019.09.11
TIL 09/10  (0) 2019.09.10
TIL 09/08  (0) 2019.09.08
TIL 09/07  (0) 2019.09.07
TIL 09/06  (0) 2019.09.06