diff options
Diffstat (limited to 'pysite/migrations/tables')
-rw-r--r-- | pysite/migrations/tables/oauth_data/v1.py | 4 | ||||
-rw-r--r-- | pysite/migrations/tables/users/__init__.py | 0 | ||||
-rw-r--r-- | pysite/migrations/tables/users/v1.py | 11 | ||||
-rw-r--r-- | pysite/migrations/tables/wiki/v1.py | 4 |
4 files changed, 19 insertions, 0 deletions
diff --git a/pysite/migrations/tables/oauth_data/v1.py b/pysite/migrations/tables/oauth_data/v1.py index dc7417bb..9ace6bf9 100644 --- a/pysite/migrations/tables/oauth_data/v1.py +++ b/pysite/migrations/tables/oauth_data/v1.py @@ -2,6 +2,10 @@ from rethinkdb import ReqlOpFailedError def run(db, table, table_obj): + """ + Create a secondary index on the "snowflake" key, so we can easily get documents by matching that key + """ + try: db.run(db.query(table).index_create("snowflake")) db.run(db.query(table).index_wait("snowflake")) diff --git a/pysite/migrations/tables/users/__init__.py b/pysite/migrations/tables/users/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/pysite/migrations/tables/users/__init__.py diff --git a/pysite/migrations/tables/users/v1.py b/pysite/migrations/tables/users/v1.py new file mode 100644 index 00000000..9ba70142 --- /dev/null +++ b/pysite/migrations/tables/users/v1.py @@ -0,0 +1,11 @@ +def run(db, table, table_obj): + """ + Remove stored email addresses from every user document + """ + + for document in db.get_all(table): + if "email" in document: + del document["email"] + + db.insert(table, document, conflict="update", durability="soft") + db.sync(table) diff --git a/pysite/migrations/tables/wiki/v1.py b/pysite/migrations/tables/wiki/v1.py index a5282f28..22670342 100644 --- a/pysite/migrations/tables/wiki/v1.py +++ b/pysite/migrations/tables/wiki/v1.py @@ -1,4 +1,8 @@ def run(db, table, table_obj): + """ + Ensure that there are no wiki articles that don't have titles + """ + for document in db.pluck(table, table_obj.primary_key, "title"): if not document.get("title"): document["title"] = "No Title" |