38086-vm/manual_db_fix.py
2026-02-10 06:55:31 +00:00

33 lines
1.4 KiB
Python

from django.db import connection
def fix_db():
print("Starting DB Fix...")
with connection.cursor() as cursor:
# 1. Check/Add is_service to core_product
try:
cursor.execute("SELECT is_service FROM core_product LIMIT 1")
print("SUCCESS: is_service already exists in core_product.")
except Exception:
print("Attempting to add is_service column...")
try:
# Try MySQL syntax first
cursor.execute("ALTER TABLE core_product ADD COLUMN is_service tinyint(1) NOT NULL DEFAULT 0;")
print("FIXED: Added is_service column to core_product.")
except Exception as e:
print(f"ERROR adding is_service: {e}")
# 2. Check/Add is_active to core_paymentmethod
try:
cursor.execute("SELECT is_active FROM core_paymentmethod LIMIT 1")
print("SUCCESS: is_active already exists in core_paymentmethod.")
except Exception:
print("Attempting to add is_active column...")
try:
cursor.execute("ALTER TABLE core_paymentmethod ADD COLUMN is_active tinyint(1) NOT NULL DEFAULT 1;")
print("FIXED: Added is_active column to core_paymentmethod.")
except Exception as e:
print(f"ERROR adding is_active: {e}")
if __name__ == '__main__':
fix_db()