Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ansible/roles/digital_ocean/setup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
register: db_check

- name: d_ocean | db | create mongodb database
ansible.builtin.command: doctl databases create {{ db_name }} --region {{ droplet_region }} --engine mongodb --version 6 --output json
ansible.builtin.command: doctl databases create {{ db_name }} --region {{ droplet_region }} --engine mongodb --version 7 --output json
async: 1800
poll: 60
register: db_create
Expand Down
20 changes: 20 additions & 0 deletions backend/btrixcloud/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

CURR_DB_VERSION = "0054"

MIN_DB_VERSION = 7.0


# ============================================================================
def resolve_db_url() -> str:
Expand Down Expand Up @@ -75,6 +77,24 @@ def init_db() -> tuple[AsyncIOMotorClient, AsyncIOMotorDatabase]:
return client, mdb


# ============================================================================
async def ensure_feature_version(client: AsyncIOMotorClient):
Comment thread
ikreymer marked this conversation as resolved.
admin = client["admin"]

fcv_status = await admin.command(
{"getParameter": 1, "featureCompatibilityVersion": 1}
)
version = fcv_status.get("featureCompatibilityVersion", {}).get("version")

if float(version) < MIN_DB_VERSION:
print(f"mongodb: updating feature compatibility {version} -> {MIN_DB_VERSION}")
await admin.command(
{"setFeatureCompatibilityVersion": str(MIN_DB_VERSION), "confirm": True}
)
else:
print(f"mongodb: feature compatibility {version} >= {MIN_DB_VERSION}")


# ============================================================================
async def ping_db(mdb) -> None:
"""run in loop until db is up, set db_inited['inited'] property to true"""
Expand Down
6 changes: 4 additions & 2 deletions backend/btrixcloud/main_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import asyncio

from .ops import init_ops
from .db import update_and_prepare_db
from .db import update_and_prepare_db, ensure_feature_version


# ============================================================================
Expand Down Expand Up @@ -38,10 +38,12 @@ async def main() -> int:
file_ops,
crawl_log_ops,
crawl_manager,
_,
dbclient,
mdb,
) = init_ops()

await ensure_feature_version(dbclient)

await update_and_prepare_db(
mdb,
user_manager,
Expand Down
2 changes: 1 addition & 1 deletion chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ mongo_local: true

mongo_host: "local-mongo"

mongo_image: "docker.io/library/mongo:6.0.5"
mongo_image: "docker.io/library/mongo:7.0"
mongo_pull_policy: "IfNotPresent"

mongo_cpu: "12m"
Expand Down
Loading