36 lines
725 B
Python
36 lines
725 B
Python
#!/usr/bin/env python3
|
|
"""Database migration script for Flask-Migrate."""
|
|
|
|
from flask.cli import FlaskGroup
|
|
|
|
from app import create_app
|
|
from app.database import db
|
|
|
|
app = create_app()
|
|
cli = FlaskGroup(app)
|
|
|
|
|
|
@cli.command()
|
|
def init_db():
|
|
"""Initialize the database."""
|
|
print("Initializing database...")
|
|
from app.database_init import init_database
|
|
|
|
init_database()
|
|
print("Database initialized successfully!")
|
|
|
|
|
|
@cli.command()
|
|
def reset_db():
|
|
"""Reset the database (drop all tables and recreate)."""
|
|
print("Resetting database...")
|
|
db.drop_all()
|
|
from app.database_init import init_database
|
|
|
|
init_database()
|
|
print("Database reset successfully!")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
cli()
|