def _upgrade_schema(engine):
 inspector = reflection.Inspector.from_engine(engine)
 conn = engine.connect()
 if ('task_id' not in [x['name'] for x in inspector.get_columns('tasks')]):
  logger.warn('Upgrading DbTaskHistory schema: Adding tasks.task_id')
  conn.execute('ALTER TABLE tasks ADD COLUMN task_id VARCHAR(200)')
  conn.execute('CREATE INDEX ix_task_id ON tasks (task_id)')

def _upgrade_schema ( engine ) : inspector = reflection . Inspector . from_engine ( engine ) conn = engine . connect ( ) if ( 'task_id' not in [ x [ 'name' ] for x in inspector . get_columns ( 'tasks' ) ] ) : logger . warn ( 'Upgrading DbTaskHistory schema: Adding tasks.task_id' ) conn . execute ( 'ALTER TABLE tasks ADD COLUMN task_id VARCHAR(200)' ) conn . execute ( 'CREATE INDEX ix_task_id ON tasks (task_id)' )
ensure the database schema is up to date with the codebase .