from flask.cli import FlaskGroup from src import create_app, db from src.api.models.users import Roles, User app = create_app() cli = FlaskGroup(create_app=create_app) @cli.command("recreate_db") def recreate_db(): db.drop_all() db.create_all() db.session.commit() @cli.command("seed_db") def seed_db(): db.session.add( User( username="lufthansa", email="info@lufthansa.com", password="password1234", role=Roles.airline, ) ) db.session.add( User( username="ryanair", email="info@ryanair.com", password="password1234", role=Roles.airline, ) ) db.session.add( User( username="admin", email="admin", password="password1234", role=Roles.admin, ) ) db.session.add( User(username="messi", email="messi@gmail.com", password="password1234") ) db.session.commit() if __name__ == "__main__": cli()