#!/bin/bash

# Enamel Wallets - Database Setup Script
# Sets up your Supabase database with complete Nigerian fintech schema

echo "🗄️ ENAMEL WALLETS - DATABASE SETUP"
echo "================================="

# Colors
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'

print_step() {
    echo -e "${GREEN}✓${NC} $1"
}

print_info() {
    echo -e "${BLUE}→${NC} $1"
}

print_warning() {
    echo -e "${YELLOW}!${NC} $1"
}

print_error() {
    echo -e "${RED}✗${NC} $1"
}

echo
print_info "Your Enamel Wallets database includes:"
print_info "✓ Users with KYC verification system"
print_info "✓ Multi-wallet system (5 wallet types per user)"
print_info "✓ Nigerian account number generation"
print_info "✓ Group savings (Ajo/Esusu) functionality"
print_info "✓ Complete transaction logging"
print_info "✓ Admin dashboard with audit trails"
print_info "✓ Notification system"
print_info "✓ Payment processing framework"

echo
print_warning "MANUAL SETUP REQUIRED:"
print_warning "1. Go to your Supabase project dashboard"
print_warning "2. Click 'SQL Editor' in the sidebar"
print_warning "3. Click 'New Query'"
print_warning "4. Copy the entire contents of DATABASE_SCHEMA.sql"
print_warning "5. Paste it into the SQL editor"
print_warning "6. Click 'Run' to execute"

echo
print_info "Your DATABASE_SCHEMA.sql contains:"
echo "   • Users table with Nigerian KYC fields (BVN, NIN)"
echo "   • Wallets table with unique account numbers"
echo "   • Transactions table with Nigerian payment types"
echo "   • Groups table for cooperative savings"
echo "   • Notifications and admin audit logs"
echo "   • Row Level Security (RLS) policies"
echo "   • Performance indexes"

echo
print_step "Database schema is ready in DATABASE_SCHEMA.sql"

echo
print_info "After running the SQL, your database will have:"
print_info "✓ Test users with Nigerian phone numbers"
print_info "✓ Sample wallets with Naira balances"
print_info "✓ Demo transactions in Nigerian format"
print_info "✓ Admin user for dashboard access"

echo
print_warning "TEST CREDENTIALS (automatically created):"
echo "User: test@enamelwallets.ng / TestUser123!"
echo "Admin: admin@enamelwallets.ng / AdminUser123!"

echo
print_step "🎯 DATABASE SETUP COMPLETE!"
print_info "Your Enamel Wallets backend is ready for testing!"