claude-code-tracker/init_db.py
Ryan Malloy 50c80596d0 Add comprehensive Docker deployment and file upload functionality
Features Added:
• Docker containerization with multi-stage Python 3.12 build
• Caddy reverse proxy integration with automatic SSL
• File upload interface for .claude.json imports with preview
• Comprehensive hook system with 39+ hook types across 9 categories
• Complete documentation system with Docker and import guides

Technical Improvements:
• Enhanced database models with hook tracking capabilities
• Robust file validation and error handling for uploads
• Production-ready Docker compose configuration
• Health checks and resource limits for containers
• Database initialization scripts for containerized deployments

Documentation:
• Docker Deployment Guide with troubleshooting
• Data Import Guide with step-by-step instructions
• Updated Getting Started guide with new features
• Enhanced documentation index with responsive grid layout

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-11 08:02:09 -06:00

49 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""
Database initialization script for Claude Code Tracker.
This script ensures the database is properly initialized before the application starts.
"""
import asyncio
import os
import sys
from pathlib import Path
# Add the app directory to the Python path
sys.path.append(str(Path(__file__).parent))
from app.database.connection import init_database, engine
async def ensure_database_initialized():
"""Ensure the database is properly initialized."""
try:
print("Initializing database...")
# Create data directory if it doesn't exist
data_dir = Path("/app/data")
data_dir.mkdir(parents=True, exist_ok=True)
# Set permissions on data directory
os.chmod(str(data_dir), 0o777)
# Initialize database
await init_database()
print("Database initialization completed successfully!")
return True
except Exception as e:
print(f"Database initialization failed: {e}")
# Don't exit - let the app try to continue
return False
finally:
# Clean up engine
try:
await engine.dispose()
except:
pass
if __name__ == "__main__":
asyncio.run(ensure_database_initialized())