35 lines
No EOL
1,013 B
Python
35 lines
No EOL
1,013 B
Python
"""
|
|
Script to run all database migrations for Podcastrr.
|
|
This script is useful when you need to apply migrations to an existing database.
|
|
"""
|
|
import os
|
|
import sys
|
|
import subprocess
|
|
|
|
def main():
|
|
"""
|
|
Run the init_db.py script to apply all migrations.
|
|
"""
|
|
print("Running database migrations...")
|
|
|
|
# Get the path to the init_db.py script
|
|
init_db_path = os.path.join(os.path.dirname(__file__), 'init_db.py')
|
|
|
|
# Run the init_db.py script
|
|
try:
|
|
result = subprocess.run([sys.executable, init_db_path],
|
|
capture_output=True,
|
|
text=True,
|
|
check=True)
|
|
print(result.stdout)
|
|
print("Migrations completed successfully!")
|
|
except subprocess.CalledProcessError as e:
|
|
print(f"Error running migrations: {e}")
|
|
print(f"Output: {e.stdout}")
|
|
print(f"Error: {e.stderr}")
|
|
return 1
|
|
|
|
return 0
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main()) |