#!/usr/bin/env python
"""
Setup local database by creating migrations and applying them
"""
import os
import django

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'branch_system.settings')
django.setup()

from django.core.management import call_command

print("=" * 80)
print("SETTING UP LOCAL DATABASE")
print("=" * 80)

print("\nStep 1: Creating migrations for all apps...")
try:
    call_command('makemigrations', verbosity=2)
    print("✓ Migrations created")
except Exception as e:
    print(f"Note: {str(e)}")

print("\nStep 2: Applying all migrations...")
try:
    call_command('migrate', verbosity=2)
    print("✓ Migrations applied")
except Exception as e:
    print(f"Error: {str(e)}")

print("\n" + "=" * 80)
print("✓ DATABASE SETUP COMPLETE")
print("=" * 80)
print("\nYour local database is now ready to use!")
