Exemplo n.º 1
0
def init_development_data(context, upgrade_db=True, skip_on_failure=False):
    """
    Fill a database with development data like default users.
    """
    if upgrade_db:
        context.invoke_execute(context, 'app.db.upgrade')

    log.info("Initializing development data...")

    import app
    flask_app = app.create_app()

    with flask_app.app_context():
        from migrations import initial_development_data
        try:
            initial_development_data.init()
        except AssertionError as exception:
            if not skip_on_failure:
                log.error("%s", exception)
            else:
                log.debug(
                    "The following error was ignored due to the `skip_on_failure` flag: %s",
                    exception
                )
                log.info("Initializing development data step is skipped.")
        else:
            log.info("Fixtures have been successfully applied.")
def init_development_data(context, upgrade_db=True, skip_on_failure=False):
    """
    Fill a database with development data like default users.
    """
    if upgrade_db:
        context.invoke_execute(context, 'app.db.upgrade')

    log.info("Initializing development data...")

    import app
    flask_app = app.create_app()

    with flask_app.app_context():
        from migrations import initial_development_data
        try:
            initial_development_data.init()
        except AssertionError as exception:
            if not skip_on_failure:
                log.error("%s", exception)
            else:
                log.debug(
                    "The following error was ignored due to the `skip_on_failure` flag: %s",
                    exception)
                log.info("Initializing development data step is skipped.")
        else:
            log.info("Fixtures have been successfully applied.")
Exemplo n.º 3
0
def init_development_data(context, skip_on_failure=False):
    """
    初始化诸如用户、用户权限等基本信息到数据库
    """

    log.info("初始化应用数据...")
    add_closure_table_procedure(context)

    from migrations import initial_development_data

    try:
        initial_development_data.init()
        initial_development_data.update_permissions()
    except AssertionError as exception:
        if not skip_on_failure:
            log.error("%s", exception)
        else:
            log.info("Initializing development data step is skipped.")
    else:
        log.info("数据初始化成功.")