aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/migrations/tables
diff options
context:
space:
mode:
Diffstat (limited to 'pysite/migrations/tables')
-rw-r--r--pysite/migrations/tables/code_jam_teams/v1.py1
-rw-r--r--pysite/migrations/tables/code_jams/v2.py10
2 files changed, 11 insertions, 0 deletions
diff --git a/pysite/migrations/tables/code_jam_teams/v1.py b/pysite/migrations/tables/code_jam_teams/v1.py
index 563a146b..165d3100 100644
--- a/pysite/migrations/tables/code_jam_teams/v1.py
+++ b/pysite/migrations/tables/code_jam_teams/v1.py
@@ -10,3 +10,4 @@ def run(db, table, table_obj):
if document["id"] in jam["teams"]:
document["jam"] = jam["number"]
db.insert(table, document, conflict="update", durability="soft")
+ db.sync(table)
diff --git a/pysite/migrations/tables/code_jams/v2.py b/pysite/migrations/tables/code_jams/v2.py
new file mode 100644
index 00000000..df4752c8
--- /dev/null
+++ b/pysite/migrations/tables/code_jams/v2.py
@@ -0,0 +1,10 @@
+def run(db, table, table_obj):
+ """
+ Clean list of teams from teams that do not exist anymore.
+ """
+ for document in db.get_all(table):
+ for team_id in document["teams"]:
+ if db.get("code_jam_teams", team_id) is None:
+ document["teams"].remove(team_id)
+ db.insert(table, document, conflict="update", durability="soft")
+ db.sync(table)