Skip to content

DB Migrations

nharlow89 edited this page Sep 10, 2014 · 5 revisions

Comment Migration

To migrate the comments from v1 to v2 (mysql to mongodb) run the following command

./artisan comment:migration

from the laravel directory. Note that if a post no longer exists in the new system, the comments related to that post will not be migrated. If the author of a comment no longer exists, the comment will still be migrated with author 'nobody'.

Comment Update Sorting Slugs

This command updates the slugs so that we can order by both desc/asc order.

./artisan comment:sorting

If you have already indexed mongo you may need to remove the previous un-used indexes. To check which fields are currently indexed, run this command in mongo cli.

db.comments.getIndexes()

If you need to drop the previously indexed (post_id, full_slug)... Note: 'post_id_1_full_slug_1' is the 'name' attribute found in the getIndexes() command.

db.comments.dropIndex('post_id_1_full_slug_1')

To add the new indexes for asc and desc slugs run the following commands

db.comments.ensureIndex({'post_id': 1, 'full_slug_asc': 1})
db.comments.ensureIndex({'post_id': 1, 'full_slug_desc': 1})
Clone this wiki locally