def check_and_init_submission_table()

in bugbounty_gpt/db/migrate.py [0:0]


def check_and_init_submission_table(engine):
    """
    Checks if the 'submission' table exists, and if not, runs an alembic migration to create it.

    :param engine: The SQLAlchemy engine to use for inspecting the database and running migrations.
    """
    inspector = inspect(engine)
    if "submission" not in inspector.get_table_names():
        logger.info("Submission table not found - attempting alembic auto-generate & init.")
        alembic_cfg = Config("/usr/src/app/alembic.ini")
        command.revision(alembic_cfg, autogenerate=True, message="Auto-generated migration for 'submission' table.")
        command.upgrade(alembic_cfg, "head")