Verified Commit 7db2095d authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Restore boards on rollback

parent 73fa5984
......@@ -11,9 +11,17 @@ def migrate_to(apps, schema_editor):
for board in boards:
TemporaryBoard.objects.create(parent=board.committee_ptr_id)
def migrate_back(apps, schema_editor):
# Reverse is not imported, objects will be deleted
pass
TemporaryBoard = apps.get_model("activemembers", "TemporaryBoard")
boards = TemporaryBoard.objects.all()
for temp_board in boards:
schema_editor.execute(
'INSERT INTO activemembers_board (committee_ptr_id, is_board)'
' VALUES ({}, 1);'
.format(temp_board.parent))
class Migration(migrations.Migration):
......
......@@ -23,7 +23,6 @@ def migrate_to(apps, schema_editor):
def migrate_back(apps, schema_editor):
schema_editor.execute('DELETE FROM activemembers_board;')
Committee = apps.get_model("activemembers", "Committee")
committees = Committee.objects.all()
for committee in committees:
......@@ -33,6 +32,14 @@ def migrate_back(apps, schema_editor):
.format(committee.wiki_namespace if committee.wiki_namespace else 'NULL', committee.membergroup_ptr_id))
schema_editor.execute('DELETE FROM activemembers_committee;')
Board = apps.get_model("activemembers", "Board")
TemporaryBoard = apps.get_model("activemembers", "TemporaryBoard")
boards = Board.objects.all()
for board in boards:
TemporaryBoard.objects.create(parent=board.membergroup_ptr_id)
schema_editor.execute('DELETE FROM activemembers_board;')
class Migration(migrations.Migration):
dependencies = [
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment