Skip to content

Commit 5aef4f7

Browse files
committed
Add migration
1 parent c41b519 commit 5aef4f7

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

backend/btrixcloud/db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
) = PageOps = BackgroundJobOps = FileUploadOps = CrawlLogOps = object
3535

3636

37-
CURR_DB_VERSION = "0050"
37+
CURR_DB_VERSION = "0051"
3838

3939

4040
# ============================================================================
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""
2+
Migration 0051 - Ensure failOnContentCheck is not set for workflows without profiles
3+
"""
4+
5+
from btrixcloud.migrations import BaseMigration
6+
7+
8+
MIGRATION_VERSION = "0051"
9+
10+
11+
# pylint: disable=duplicate-code
12+
class Migration(BaseMigration):
13+
"""Migration class."""
14+
15+
# pylint: disable=unused-argument
16+
def __init__(self, mdb, **kwargs):
17+
super().__init__(mdb, migration_version=MIGRATION_VERSION)
18+
19+
async def migrate_up(self) -> None:
20+
"""Perform migration up.
21+
22+
Unset failOnContentCheck for workflows that don't have a profile set
23+
"""
24+
crawl_configs_mdb = self.mdb["crawl_configs"]
25+
26+
try:
27+
await crawl_configs_mdb.update_many(
28+
{"profileid": None, "config.failOnContentCheck": True},
29+
{"$set": {"config.failOnContentCheck": False}},
30+
)
31+
32+
# pylint: disable=broad-exception-caught
33+
except Exception as err:
34+
print(
35+
f"Error unsetting failOnContentCheck for configs without profiles: {err}",
36+
flush=True,
37+
)

0 commit comments

Comments
 (0)