54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
|
|
#!/usr/bin/env python
|
|||
|
|
# -*- coding: utf-8 -*-
|
|||
|
|
"""
|
|||
|
|
检查license表结构
|
|||
|
|
"""
|
|||
|
|
|
|||
|
|
import sys
|
|||
|
|
import os
|
|||
|
|
from sqlalchemy import text
|
|||
|
|
|
|||
|
|
# 添加项目路径
|
|||
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|||
|
|
|
|||
|
|
from app import create_app, db
|
|||
|
|
|
|||
|
|
def check_license_table():
|
|||
|
|
"""检查license表结构"""
|
|||
|
|
app = create_app()
|
|||
|
|
|
|||
|
|
with app.app_context():
|
|||
|
|
try:
|
|||
|
|
# 检查当前表结构
|
|||
|
|
result = db.session.execute(text('PRAGMA table_info(license)'))
|
|||
|
|
columns = result.fetchall()
|
|||
|
|
|
|||
|
|
print("=== License表结构 ===")
|
|||
|
|
for column in columns:
|
|||
|
|
print(f"列名: {column[1]}, 类型: {column[2]}, 是否可为空: {column[3]}, 默认值: {column[4]}, 是否为主键: {column[5]}")
|
|||
|
|
|
|||
|
|
# 检查license_key列
|
|||
|
|
license_key_info = None
|
|||
|
|
for column in columns:
|
|||
|
|
if column[1] == 'license_key':
|
|||
|
|
license_key_info = column
|
|||
|
|
break
|
|||
|
|
|
|||
|
|
if license_key_info:
|
|||
|
|
current_type = license_key_info[2]
|
|||
|
|
print(f"\nlicense_key列类型: {current_type}")
|
|||
|
|
|
|||
|
|
if "VARCHAR(35)" in current_type.upper():
|
|||
|
|
print("✓ license_key列已经是正确的长度")
|
|||
|
|
else:
|
|||
|
|
print("✗ license_key列长度不正确,需要更新")
|
|||
|
|
else:
|
|||
|
|
print("✗ 未找到license_key列!")
|
|||
|
|
|
|||
|
|
except Exception as e:
|
|||
|
|
print(f"检查表结构时出错: {e}")
|
|||
|
|
import traceback
|
|||
|
|
traceback.print_exc()
|
|||
|
|
|
|||
|
|
if __name__ == "__main__":
|
|||
|
|
check_license_table()
|