add go bench client
This commit is contained in:
44
backend/apply_migration_012.py
Normal file
44
backend/apply_migration_012.py
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Apply migration 012: Add pci_device_id field
|
||||
"""
|
||||
import sqlite3
|
||||
import os
|
||||
|
||||
DB_PATH = "/home/gilles/projects/serv_benchmark/backend/data/peripherals.db"
|
||||
|
||||
def apply_migration():
|
||||
if not os.path.exists(DB_PATH):
|
||||
print(f"❌ Database not found: {DB_PATH}")
|
||||
return False
|
||||
|
||||
conn = sqlite3.connect(DB_PATH)
|
||||
cursor = conn.cursor()
|
||||
|
||||
try:
|
||||
# Check if column already exists
|
||||
cursor.execute("PRAGMA table_info(peripherals)")
|
||||
columns = [col[1] for col in cursor.fetchall()]
|
||||
|
||||
if "pci_device_id" in columns:
|
||||
print("✅ Column pci_device_id already exists, skipping migration")
|
||||
return True
|
||||
|
||||
# Add the column
|
||||
print("📝 Adding pci_device_id column...")
|
||||
cursor.execute("ALTER TABLE peripherals ADD COLUMN pci_device_id VARCHAR(20)")
|
||||
conn.commit()
|
||||
|
||||
print("✅ Migration 012 applied successfully")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Error applying migration: {e}")
|
||||
conn.rollback()
|
||||
return False
|
||||
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
apply_migration()
|
||||
Reference in New Issue
Block a user