46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
"""
|
|
Migrate insurance_approvals with foreign key checks disabled.
|
|
"""
|
|
import os
|
|
import sys
|
|
import django
|
|
from django.db import connection
|
|
|
|
# Setup Django
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'hospital_management.settings')
|
|
django.setup()
|
|
|
|
from django.core.management import call_command
|
|
|
|
print("Starting insurance_approvals migration with FK checks disabled...")
|
|
|
|
# Disable foreign key checks
|
|
with connection.cursor() as cursor:
|
|
cursor.execute("PRAGMA foreign_keys = OFF;")
|
|
print("✓ Foreign key checks disabled")
|
|
|
|
try:
|
|
# Run the migration
|
|
print("\nRunning migration...")
|
|
call_command('migrate', 'insurance_approvals', verbosity=2)
|
|
print("\n✓ Migration completed successfully!")
|
|
|
|
except Exception as e:
|
|
print(f"\n✗ Migration failed: {e}")
|
|
sys.exit(1)
|
|
|
|
finally:
|
|
# Re-enable foreign key checks
|
|
with connection.cursor() as cursor:
|
|
cursor.execute("PRAGMA foreign_keys = ON;")
|
|
print("\n✓ Foreign key checks re-enabled")
|
|
|
|
print("\n" + "="*60)
|
|
print("Insurance Approvals module is now ready to use!")
|
|
print("="*60)
|
|
print("\nNext steps:")
|
|
print("1. Access admin: http://127.0.0.1:8000/admin/insurance_approvals/")
|
|
print("2. Create approval templates")
|
|
print("3. Test creating approval requests")
|
|
print("\nModule successfully installed! ✓")
|