aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/migrations/tables
diff options
context:
space:
mode:
authorGravatar momothereal <[email protected]>2018-06-23 17:48:43 -0400
committerGravatar momothereal <[email protected]>2018-06-23 17:48:43 -0400
commit6ce048d6b3c5518ada39022b164c4aec41c7f5c9 (patch)
treea5230460f720f5536f0c4ee8dacab82a8a105f56 /pysite/migrations/tables
parent[API] Check for DB-nuking empty data in users POST (diff)
[Jams/Teams] Simplify getting the code jam for a team (team -> jam)
Diffstat (limited to 'pysite/migrations/tables')
-rw-r--r--pysite/migrations/tables/code_jam_teams/__init__.py0
-rw-r--r--pysite/migrations/tables/code_jam_teams/v1.py12
2 files changed, 12 insertions, 0 deletions
diff --git a/pysite/migrations/tables/code_jam_teams/__init__.py b/pysite/migrations/tables/code_jam_teams/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/pysite/migrations/tables/code_jam_teams/__init__.py
diff --git a/pysite/migrations/tables/code_jam_teams/v1.py b/pysite/migrations/tables/code_jam_teams/v1.py
new file mode 100644
index 00000000..563a146b
--- /dev/null
+++ b/pysite/migrations/tables/code_jam_teams/v1.py
@@ -0,0 +1,12 @@
+def run(db, table, table_obj):
+ """
+ Associate the ID of each team's code jam (team -> jam)
+ """
+
+ 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")