# Database Commands Module
# Commands for database setup, migrations, backup, and management

# Set shell for commands
set shell := ["bash", "-c"]

# Database setup and initialization (default)
setup:
    @echo "🗄️ Setting up database..."
    {{justfile_directory()}}/scripts/databases/db.sh setup setup

# Create database
create:
    @echo "🗄️ Creating database..."
    {{justfile_directory()}}/scripts/databases/db.sh setup create

# Run database migrations
migrate:
    @echo "🗄️ Running database migrations..."
    {{justfile_directory()}}/scripts/databases/db.sh migrate run

# Create new migration
migration name:
    @echo "🗄️ Creating new migration: {{name}}..."
    {{justfile_directory()}}/scripts/databases/db.sh migrate create --name {{name}}

# Database status
status:
    @echo "🗄️ Checking database status..."
    {{justfile_directory()}}/scripts/databases/db.sh status

# Database health check
health:
    @echo "🗄️ Running database health check..."
    {{justfile_directory()}}/scripts/databases/db.sh health

# Reset database (drop + create + migrate)
reset:
    @echo "🗄️ Resetting database..."
    {{justfile_directory()}}/scripts/databases/db.sh setup reset

# Backup database
backup:
    @echo "🗄️ Creating database backup..."
    {{justfile_directory()}}/scripts/databases/db.sh backup create

# Restore database from backup
restore file:
    @echo "🗄️ Restoring database from {{file}}..."
    {{justfile_directory()}}/scripts/databases/db.sh backup restore --file {{file}}

# Database monitoring
monitor:
    @echo "🗄️ Starting database monitoring..."
    {{justfile_directory()}}/scripts/databases/db.sh monitor monitor

# Show database size
size:
    @echo "🗄️ Showing database size..."
    {{justfile_directory()}}/scripts/databases/db.sh utils size

# Optimize database
optimize:
    @echo "🗄️ Optimizing database..."
    {{justfile_directory()}}/scripts/databases/db.sh utils optimize
