Files
Document_Translator/recreate_notification_table.py
2025-09-04 09:44:13 +08:00

41 lines
1.2 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
重新創建通知表腳本
"""
from app import create_app, db
from app.models import Notification
def recreate_notification_table():
"""重新創建通知表"""
try:
app = create_app()
with app.app_context():
print("Recreating notification table...")
# 刪除通知表(如果存在)
try:
db.engine.execute('DROP TABLE IF EXISTS dt_notifications')
print("✅ Old notification table dropped")
except Exception as e:
print(f"Info: {e}")
# 重新創建通知表
db.create_all()
print("✅ New notification table created with correct structure")
# 檢查表結構
result = db.engine.execute('DESCRIBE dt_notifications')
columns = result.fetchall()
print("\nNew table structure:")
for col in columns:
print(f" {col[0]} {col[1]}")
except Exception as e:
print(f"Error recreating notification table: {e}")
import traceback
traceback.print_exc()
if __name__ == '__main__':
recreate_notification_table()