fix: system_all_log.html ReferenceError and other updates
This commit is contained in:
43
manual_migration.py
Normal file
43
manual_migration.py
Normal file
@@ -0,0 +1,43 @@
|
||||
import sqlite3
|
||||
import os
|
||||
|
||||
db_path = '/Volumes/WD/Users/Work/python/flaskfarm/data/db/gds_dviewer.db'
|
||||
table_name = 'gds_dviewer_file_index'
|
||||
|
||||
print(f"Checking DB: {db_path}")
|
||||
if not os.path.exists(db_path):
|
||||
print("Error: DB file not found")
|
||||
exit(1)
|
||||
|
||||
conn = sqlite3.connect(db_path)
|
||||
cursor = conn.cursor()
|
||||
|
||||
# Check columns
|
||||
cursor.execute(f"PRAGMA table_info({table_name})")
|
||||
columns = [row[1] for row in cursor.fetchall()]
|
||||
print(f"Current columns: {columns}")
|
||||
|
||||
# Add columns if missing
|
||||
changed = False
|
||||
if 'meta_id' not in columns:
|
||||
print(f"Adding meta_id to {table_name}")
|
||||
cursor.execute(f"ALTER TABLE {table_name} ADD COLUMN meta_id VARCHAR(64)")
|
||||
try:
|
||||
cursor.execute(f"CREATE INDEX ix_{table_name}_meta_id ON {table_name} (meta_id)")
|
||||
print("Created index for meta_id")
|
||||
except Exception as e:
|
||||
print(f"Index creation hint/error: {e}")
|
||||
changed = True
|
||||
|
||||
if 'meta_poster' not in columns:
|
||||
print(f"Adding meta_poster to {table_name}")
|
||||
cursor.execute(f"ALTER TABLE {table_name} ADD COLUMN meta_poster VARCHAR(1024)")
|
||||
changed = True
|
||||
|
||||
if changed:
|
||||
conn.commit()
|
||||
print("Migration successful")
|
||||
else:
|
||||
print("No changes needed")
|
||||
|
||||
conn.close()
|
||||
Reference in New Issue
Block a user