1 | # Fixes migrations for people who are coming pre-current migrations :)
|
---|
2 |
|
---|
3 | import os
|
---|
4 | import sys
|
---|
5 | import pymongo
|
---|
6 |
|
---|
7 | print "*** WARNING! ***"
|
---|
8 | print " This script is ONLY for people who have data pre-modern migrations."
|
---|
9 | print " If that's not you, don't run this!"
|
---|
10 | print " Also makes the following assumptions:"
|
---|
11 | print " - that you're running this on local branch 'master'"
|
---|
12 | print " - that your master branch is up to date with latest mediagoblin"
|
---|
13 | print " master"
|
---|
14 | print " - You're running on database 'mediagoblin' on standard"
|
---|
15 | print " connection parameters"
|
---|
16 | print " - You're running this out of buildout"
|
---|
17 | print " - That you don't have any modified files in your git checkout"
|
---|
18 | print ""
|
---|
19 | print "Consider yourself warned!"
|
---|
20 |
|
---|
21 | run_it = raw_input(
|
---|
22 | 'Are you SURE you want to run this? (if so, type "yes")> ')
|
---|
23 |
|
---|
24 | if not run_it == 'yes':
|
---|
25 | sys.exit(1)
|
---|
26 |
|
---|
27 | print "~*** First applying old migrations... ***~\n"
|
---|
28 | os.popen('git checkout 6ae8b541f957b49ae86051814097e769d20f29af')
|
---|
29 | os.popen('echo "Old migrations running..." > migration_result.txt')
|
---|
30 | os.popen('echo "=========================" >> migration_result.txt')
|
---|
31 | os.popen('./bin/gmg migrate >> migration_result.txt')
|
---|
32 |
|
---|
33 | print "~*** Okay, now making sure your database is unmigrated... ***~\n"
|
---|
34 | db = pymongo.Connection()['mediagoblin']
|
---|
35 | db.drop_collection('app_metadata')
|
---|
36 | db['app_metadata'].update(
|
---|
37 | {u'_id': u'mediagoblin'},
|
---|
38 | {u'$set': {u'current_migration': 0}},
|
---|
39 | upsert=True)
|
---|
40 |
|
---|
41 | print "~*** Checking back out master and running migrations... ***~\n"
|
---|
42 | os.popen('git checkout master')
|
---|
43 | os.popen('echo "\nNew migrations running..." >> migration_result.txt')
|
---|
44 | os.popen('echo "=========================" >> migration_result.txt')
|
---|
45 | os.popen('./bin/gmg migrate >> migration_result.txt')
|
---|
46 |
|
---|
47 | print "done, migration output available in migration_result.txt"
|
---|