~jcsackett/charmworld/bac-tag-constraints

« back to all changes in this revision

Viewing changes to charmworld/migrations/versions/011_ensure_category_questions.py

  • Committer: Tarmac
  • Author(s): Aaron Bentley
  • Date: 2013-08-06 14:09:18 UTC
  • mfrom: (328.1.7 restore-questions)
  • Revision ID: tarmac-20130806140918-d8nkgw3oynufkb7p
[r=bac][bug=][author=abentley] Restore QA questions to migrations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2013 Canonical Ltd.  This software is licensed under the
 
2
# GNU Affero General Public License version 3 (see the file LICENSE).
 
3
 
 
4
from charmworld.qa_questions import iter_categories
 
5
 
 
6
 
 
7
def upgrade(db, index_client):
 
8
    """Update each category of questions from new_category_data.
 
9
 
 
10
    This update elaborates on the 001_* migration. Subsequent qa form
 
11
    migrations can replace new_category_data and run this same method.
 
12
    """
 
13
    db.qa.drop()
 
14
    for category_dict in iter_categories():
 
15
        db.qa.insert(category_dict)