From 1e295d582afc1d151b9ad7d40be3a16c881f9f88 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Tue, 19 Jun 2018 13:11:14 +0100 Subject: [DB] Migration for code_jams to add teams list to all documents --- pysite/migrations/tables/code_jams/v1.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 pysite/migrations/tables/code_jams/v1.py (limited to 'pysite/migrations/tables/code_jams/v1.py') diff --git a/pysite/migrations/tables/code_jams/v1.py b/pysite/migrations/tables/code_jams/v1.py new file mode 100644 index 00000000..cce3b112 --- /dev/null +++ b/pysite/migrations/tables/code_jams/v1.py @@ -0,0 +1,11 @@ +def run(db, table, table_obj): + """ + Add "teams" list to jams without it + """ + + for document in db.get_all(table): + if "teams" not in document: + document["teams"] = [] + + db.insert(table, document, conflict="replace", durability="soft") + db.sync(table) -- cgit v1.2.3