예제 #1
0
def db_handler(args):
    """db_handler."""

    if args.type == 'create':
        if args.db is None:
            db.init_db()
        return

    if not db.setup(url=args.db, echo=args.db_echo):
        return

    if args.type == 'status':
        current_rev = db_revision.current_db_revision()
        print('The current DB schema version:', current_rev)

    if args.type == 'upgrade':
        db.upgrade()

    if args.type == 'revision':
        db_revision.new_revision()

    if args.type == 'drop':
        if args.db is not None:
            db.downgrade()
        db.remove_db()
예제 #2
0
def _check_db_revision():
    if not db_revision.check_current_db_revision():
        command = '\'chainerui db upgrade\''
        if db_revision.current_db_revision() is None:
            command = 'both \'chainerui db create\' and ' + command
        print('The current DB schema version is not supported.')
        print('Please run {} command before.'.format(command))
        return False
    return True
예제 #3
0
파일: app.py 프로젝트: speedcell4/chainerui
def _check_db_revision():
    if not db_revision.check_current_db_revision():
        command = 'upgrade'
        if db_revision.current_db_revision() is None:
            command = 'setup'
        msg = 'The current DB schema version is not supported, ' +\
            'please %s DB' % command
        print(msg)
        return False
    return True
예제 #4
0
파일: app.py 프로젝트: speedcell4/chainerui
def db_handler(args):
    """db_handler."""

    if args.type == 'create':
        create_db()

    if args.type == 'status':
        current_rev = db_revision.current_db_revision()
        print('current_rev', current_rev)

    if args.type == 'upgrade':
        upgrade_db()

    if args.type == 'revision':
        db_revision.new_revision()

    if args.type == 'drop':
        if os.path.exists(DB_FILE_PATH):
            os.remove(DB_FILE_PATH)