-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcleanup_migrations.sh
executable file
·30 lines (27 loc) · 1.06 KB
/
cleanup_migrations.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# This shell script is used to delete ALL migration files in the project.
# After running the script, you will lose all your migration history.
# By Sichen Li.
# Find all migration directories
files_to_delete=$(find . -path "*/migrations/*.py" -not -name "__init__.py")
pyc_files_to_delete=$(find . -path "*/migrations/*.pyc")
pyc_files_to_delete_2=$(find . -path "*/__pycache__/*.pyc")
# Print out the files that are going to be deleted
echo "The following .py files will be deleted:"
echo "$files_to_delete"
echo "-----------------------------------------"
echo "The following .pyc files will be deleted:"
echo "$pyc_files_to_delete"
echo "$pyc_files_to_delete_2"
# Ask for confirmation
read -p "Are you **really** sure you want to delete these files? (y/N) " confirm
if [[ "$confirm" == [yY] ]]
then
echo "-----------------------------------------"
echo "Deleting files..."
echo "$files_to_delete" | xargs rm
echo "$pyc_files_to_delete" | xargs rm
echo "$pyc_files_to_delete_2" | xargs rm
echo "Done. Wish you have a fresh restart!"
else
echo "Aborted."
fi