28 lines
632 B
Python
28 lines
632 B
Python
#!/usr/bin/env python3
|
|
"""Database migration script for Flask-Migrate."""
|
|
|
|
import os
|
|
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...")
|
|
db.create_all()
|
|
print("Database initialized successfully!")
|
|
|
|
@cli.command()
|
|
def reset_db():
|
|
"""Reset the database (drop all tables and recreate)."""
|
|
print("Resetting database...")
|
|
db.drop_all()
|
|
db.create_all()
|
|
print("Database reset successfully!")
|
|
|
|
if __name__ == "__main__":
|
|
cli() |