code: def configure_db(app):
      
      models.db.init_app(app)
      log = logging.getLogger('ara.webapp.configure_db')
      log.debug('Setting up database...')
  
      if app.config.get('ARA_AUTOCREATE_DATABASE'):
          with app.app_context():
              migrations = app.config['DB_MIGRATIONS']
              flask_migrate.Migrate(app, models.db, directory=migrations)
              config = app.extensions['migrate'].migrate.get_config(migrations)
  
              # Verify if the database tables have been created at all
              inspector = Inspector.from_engine(models.db.engine)
              if len(inspector.get_table_names()) == 0:
                  log.info('Initializing new DB from scratch')
                  flask_migrate.upgrade(directory=migrations)
  
              # Get current alembic head revision
              script = ScriptDirectory.from_config(config)
              head = script.get_current_head()
  
              # Get current revision, if available
              connection = models.db.engine.connect()
              context = MigrationContext.configure(connection)
              current = context.get_current_revision()
  
              if not current:
                  log.info('Unstable DB schema, stamping original revision')
                  flask_migrate.stamp(directory=migrations,
                                      revision='da9459a1f71c')
  
              if head != current:
                  log.info('DB schema out of date, upgrading')
                  flask_migrate.upgrade(directory=migrations)
docs: 0.10 is the first version of ARA that ships with a stable database schema.
      We can identify a database that originates from before this by checking if
      there is an alembic revision available.
      If there is no alembic revision available, assume we are running the first
      revision which contains the latest state of the database prior to this.