Skip to content

Instantly share code, notes, and snippets.

@seejee
Last active December 14, 2015 04:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save seejee/5031415 to your computer and use it in GitHub Desktop.
Save seejee/5031415 to your computer and use it in GitHub Desktop.
  1. Migrate the db.

  2. Copy 'temp_session.dump' from the 'ttm-utilities' S3 bucket.

  3. Restore the dump to the master shard: (Ignore any warnings about the zmance user ... nailed it.)

    pg_restore -U -h -p -d -t tmp_session_last_attempt_date temp_session.dump

  4. Add an index to the temp table:

    CREATE INDEX ON tmp_session_last_attempt_date (session_id);

  5. Run this on the master shard: (may take up to an hour)

    UPDATE student_sessions SET last_attempt_date = t.last_attempt_date FROM tmp_session_last_attempt_date t WHERE student_sessions.id = t.session_id;

  6. Drop the temp table from the master shard:

    DROP TABLE tmp_session_last_attempt;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment