File size: 1,089 Bytes
bd54343
 
 
 
d4255ec
275b1e7
d4255ec
bd54343
275b1e7
bd54343
d4255ec
 
 
 
 
 
 
bd54343
d4255ec
bd54343
 
 
d4255ec
bd54343
 
d4255ec
bd54343
 
 
d4255ec
bd54343
d4255ec
bd54343
 
 
d4255ec
bd54343
 
d4255ec
 
bd54343
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
"""
Database migration script for the TTS API.
"""
import os
import sys
import logging
from pathlib import Path

# Set up logging
logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)

def run_migrations():
    """Run database migrations."""
    try:
        # Log current environment
        logger.info(f"Current directory: {os.getcwd()}")
        logger.info(f"Python Path (sys.path): {sys.path}")
        
        # Import the database configuration
        from app.models import init_db
        
        # Initialize database tables
        init_db()
        logger.info("Database tables created successfully")
        
        return True
        
    except ImportError as e:
        logger.error(f"Error importing database configuration: {e}")
        return False
    except Exception as e:
        logger.error(f"Error running migrations: {e}")
        return False

if __name__ == "__main__":
    success = run_migrations()
    sys.exit(0 if success else 1)