
- Updated migrations/env.py to add project root to Python path - Created run_migrations.py helper script for running migrations - Updated README with instructions for using the helper script - Fixed the 'No module named app' error when running migrations
25 lines
685 B
Python
Executable File
25 lines
685 B
Python
Executable File
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
Helper script to run Alembic migrations with the correct Python path.
|
|
Usage:
|
|
python run_migrations.py upgrade head
|
|
python run_migrations.py revision --autogenerate -m "description"
|
|
python run_migrations.py --help
|
|
"""
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Add the project root directory to the Python path
|
|
BASE_DIR = Path(__file__).resolve().parent
|
|
sys.path.append(str(BASE_DIR))
|
|
print(f"Added {BASE_DIR} to Python path")
|
|
|
|
if __name__ == "__main__":
|
|
# Import alembic's main function
|
|
from alembic.config import main
|
|
|
|
# Execute alembic command with sys.argv (e.g., 'upgrade', 'head')
|
|
main(argv=sys.argv[1:]) |