[FIX] forward port ensure_db fix from saas-3