Some checks failed
CD Pipeline / deploy (push) Failing after 59s
- 建立 Gitea Actions CD pipeline (.gitea/workflows/cd.yaml) - 部署模式: rsync Python 檔案至 188 → docker restart (volume mount) - Dockerfile/requirements 變動時自動重建 Docker image - 部署通知: Telegram (開始/成功/失敗) - 健康檢查: https://mo.wooo.work/health (最多 5 次重試) - 同步最新 CLAUDE.md / ADR-008 / memory (2026-04-19) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
48 lines
1.2 KiB
Python
48 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
清除缺貨資料表
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
from database.vendor_manager import VendorDatabaseManager
|
|
from database.vendor_models import VendorStockout
|
|
|
|
def clear_stockout_data():
|
|
"""清除所有缺貨資料"""
|
|
|
|
db = VendorDatabaseManager()
|
|
session = db.get_session()
|
|
|
|
try:
|
|
# 統計資料數量
|
|
count = session.query(VendorStockout).count()
|
|
|
|
print("=" * 80)
|
|
print(f"清除缺貨資料")
|
|
print("=" * 80)
|
|
print(f"\n目前資料庫中有 {count} 筆缺貨資料")
|
|
print(f"\n⚠️ 即將清除所有資料!")
|
|
|
|
# 刪除所有記錄
|
|
session.query(VendorStockout).delete()
|
|
session.commit()
|
|
|
|
print(f"\n✅ 已清除 {count} 筆資料")
|
|
print(f"\n現在可以重新匯入正確的 Excel 資料了")
|
|
print("=" * 80)
|
|
|
|
except Exception as e:
|
|
session.rollback()
|
|
print(f"\n❌ 錯誤: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
finally:
|
|
session.close()
|
|
|
|
if __name__ == '__main__':
|
|
clear_stockout_data()
|