Commit 021e37b2 by Kevin Falcone

Merge pull request #2931 from edx/jibsheet/csmhe-util-updates

Open Sourcing our csmh migration scripts
parents 2297832f 86725415
......@@ -4,7 +4,7 @@
#
# ansible-playbook -c local -i 'localhost,' create_dbs_and_users.yml -e@./db.yml
#
# where the content of dbs.yml contains the following dictionaries
# where the content of db.yml contains the following dictionaries
#
# database_connection: &default_connection
# login_host: "mysql.example.org"
......
MINID=0
MAXID=1003426362
STEP=10000
MIGRATE_USER=migrate
PASSWORD='secret-password'
HOST='my-database-instance'
for ((i=0; i<=$MAXID; i+=$STEP)); do
echo -n "$i";
mysql -u $MIGRATE_USER -p$PASSWORD -h $HOST wwc <<EOF
INSERT INTO edxapp_csmh.coursewarehistoryextended_studentmodulehistoryextended (id, version, created, state, grade, max_grade, student_module_id)
SELECT id, version, created, state, grade, max_grade, student_module_id
FROM wwc.courseware_studentmodulehistory
WHERE id BETWEEN $i AND $(($i+$STEP-1));
EOF
echo '.';
sleep 2
done
MINID=0
MAXID=1003426362
STEP=10000
MIGRATE_USER=migrate
PASSWORD='secret-password'
HOST='my-database-instance'
for ((i=$MINID-1; i<=$MAXID; i+=$STEP)); do
echo -n "$i";
mysql -u $MIGRATE_USER -p$PASSWORD -h $HOST wwc <<EOF
INSERT INTO wwc.coursewarehistoryextended_studentmodulehistoryextended (id, version, created, state, grade, max_grade, student_module_id)
SELECT id, version, created, state, grade, max_grade, student_module_id
FROM wwc.courseware_studentmodulehistory
WHERE id BETWEEN $i AND $(($i+$STEP-1));
EOF
echo '.';
sleep 2;
done
MINID=0
MAXID=1003426362
STEP=20000
MIGRATE_USER=migrate
PASSWORD='secret'
HOST='host'
for ((i=$MINID-1; i<=$MAXID; i+=$STEP)); do
echo -n "$i";
time mysql -u $MIGRATE_USER -p$PASSWORD -h $HOST wwc <<EOF
DELETE FROM courseware_studentmodulehistory where id < $i
EOF
sleep 3;
done
Markdown is supported
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