3149770887
Remove Gate scout auto-seeding and the manual hub login button while keeping Gate login and instance SSO. Add password change and database backup/restore, plus deploy scripts with env auto-generation. Co-authored-by: Cursor <cursoragent@cursor.com>
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""可选:从数据库中删除「Gate 扫单」分组及其下属服务。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
sys.path.insert(0, str(ROOT))
|
|
|
|
from app import create_app # noqa: E402
|
|
from models import Service, ServiceGroup, db # noqa: E402
|
|
|
|
GROUP_NAMES = ("Gate 扫单",)
|
|
|
|
|
|
def main() -> None:
|
|
app = create_app()
|
|
with app.app_context():
|
|
removed_groups = 0
|
|
removed_services = 0
|
|
for name in GROUP_NAMES:
|
|
group = ServiceGroup.query.filter_by(name=name).first()
|
|
if not group:
|
|
continue
|
|
count = Service.query.filter_by(group_id=group.id).count()
|
|
db.session.delete(group)
|
|
removed_groups += 1
|
|
removed_services += count
|
|
if removed_groups:
|
|
db.session.commit()
|
|
print(
|
|
f"已删除 {removed_groups} 个分组、{removed_services} 个服务。"
|
|
" 请刷新导航首页。"
|
|
)
|
|
else:
|
|
print("未找到「Gate 扫单」分组,无需清理。")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|