新功能: 增加一键删除迁移文件的脚本

pull/57/MERGE
猿小天 2022-05-16 20:37:52 +08:00
parent a3386cc6a6
commit da661ec575
1 changed files with 15 additions and 0 deletions

15
backend/del_migrations.py Normal file
View File

@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
import os
exclude = ["venv"] # 需要排除的文件目录
for root, dirs, files in os.walk('.'):
dirs[:] = [d for d in set(dirs) - set(exclude)]
if 'migrations' in dirs:
dir = dirs[dirs.index('migrations')]
for root_j, dirs_j, files_j in os.walk(os.path.join(root, dir)):
for file_k in files_j:
if file_k != '__init__.py':
dst_file = os.path.join(root_j, file_k)
print('删除文件>>> ', dst_file)
os.remove(dst_file)