Skip to content

Instantly share code, notes, and snippets.

@jimklo
Created May 8, 2012 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimklo/2638166 to your computer and use it in GitHub Desktop.
Save jimklo/2638166 to your computer and use it in GitHub Desktop.
LR Upgrade Filter

Migrate pre 0.23.6 resource_data to 0.23.6 resource_data

  1. add the design doc for filtering to the old resource_data

    curl -H 'Content-type: application/json' -X POST 'http://localhost:5984/resource_data_big' --data-binary @design_doc.js

  2. create new target resource_data db

    curl -H 'Content-type: application/json' -X PUT 'http://localhost:5984/resource_data'

  3. start replication from the old resource db to a new one

    curl -H 'Content-type: application/json' -X POST 'http://localhost:5984/_replicator' --data-binary @replication_doc.js

  4. compact new resource_data db in the background - this takes a long time depending upon how big your resource_data db. curl -H 'Content-type: application/json' -X POST 'http://localhost:5984/resource_data/_compact' &

{
"_id": "_design/lr_upgrade",
"couchapp": {
"signatures": {},
"objects": {},
"manifest": ["filters/", "filters/resources_only.js", "lists/", "shows/", "updates/", "views/"]
},
"updates": {},
"filters": {
"resources_only": "function(doc, req) {\n if (doc.doc_type && doc.doc_type === \"resource_data\") {\n return true;\n } else {\n return false;\n } \n}"
},
"views": {},
"lists": {},
"shows": {}
}
{
"_id": "lr_upgrade",
"source": "resource_data_big",
"target": "resource_data",
"filter": "lr_upgrade/resources_only"
}
@joehobson
Copy link

  1. start replication from the old resource db to a new one ...

is there any way to monitor progress for the migration? I ran step 3 fifteen minutes ago and i'm still showing 0 records in resource_data db.

Also: step 4 command is still missing a single quote before the couch url.

@jimklo
Copy link
Author

jimklo commented May 14, 2012 via email

@joehobson
Copy link

I think i found the error: "unauthorized to access or create database resource_data" My installation is using admin party for couch so that shouldn't be the case.

Digging into it further, it appears that couch still sees the database files there after you delete the db, even if you don't see the files in the data directory. I deleted my replicator and resource_data dbs to back up and start over, but got this error: "The database could not be created, the file already exists" even though the files didn't exist in the directory. They must be in memory because bouncing couch and trying it again cleared it up.

Everything seems to be working with it now and i'm seeing all of my docs correctly. Thanks for your help.

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