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/v2.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/pysite/migrations/tables/code_jam_teams/v2.py b/pysite/migrations/tables/code_jam_teams/v2.py
new file mode 100644
index 00000000..c6d7c972
--- /dev/null
+++ b/pysite/migrations/tables/code_jam_teams/v2.py
@@ -0,0 +1,13 @@
+def run(db, table, table_obj):
+ """
+ Associate the ID of each team's code jam (team -> jam) - again
+ """
+
+ for document in db.get_all(table):
+ if "jam" not in document:
+ # find the code jam containing this team
+ for jam in db.get_all("code_jams"):
+ if document["id"] in jam["teams"]:
+ document["jam"] = jam["number"]
+ db.insert(table, document, conflict="update", durability="soft")
+ db.sync(table)