{"id":12479,"date":"2021-12-21T08:00:29","date_gmt":"2021-12-21T16:00:29","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=12479"},"modified":"2025-06-13T22:40:20","modified_gmt":"2025-06-14T05:40:20","slug":"migrating-buckets-to-collections-scopes-via-eventing-part-2","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/","title":{"rendered":"Migrating Buckets to Collections &amp; Scopes via Eventing: Part 2"},"content":{"rendered":"<h2>Migrating Buckets to Collections &amp; Scopes via Eventing: Part 2<\/h2>\n<p>Again (as I did in Part 1) I want to point out an excellent blog written by Shivani Gupta, <a href=\"https:\/\/www.couchbase.com\/blog\/how-to-migrate-to-scopes-and-collections-in-couchbase-7-0\/\" target=\"_blank\" rel=\"noopener\">How to Migrate to Scopes &amp; Collections in Couchbase 7.0<\/a>, which covers in great detail other methods of migrating bucket-based documents to Scopes and Collections in Couchbase.\u00a0 I encourage you to also read about the multiple non-Eventing methods that Shivani touches upon.<\/p>\n<blockquote><p><strong>Whether you\u2019re new to Couchbase or<\/strong> a seasoned vet, you\u2019ve likely heard about Scopes and Collections. If you\u2019re ready to try them, this article helps you make it happen.<\/p>\n<p>Scopes and Collections are a new feature introduced in <a href=\"https:\/\/www.couchbase.com\/blog\/couchbase-server-7-0-release\/?ref=blog\" target=\"_blank\" rel=\"noopener\">Couchbase Server 7.0<\/a>\u00a0that allows you to logically organize data within Couchbase. To learn more,\u00a0<a href=\"https:\/\/www.couchbase.com\/blog\/scopes-and-collections-for-modern-multi-tenant-applications-couchbase-7-0\/?ref=blog\" target=\"_blank\" rel=\"noopener\">read this introduction to Scopes and Collections<\/a>.<\/p>\n<p>You should take advantage of Scopes and Collections if you want to map your legacy RDBMS to a document database or if you\u2019re trying to consolidate hundreds of microservices and\/or tenants into a single\u00a0<a href=\"https:\/\/www.couchbase.com\/products\/capella\/\" target=\"_blank\" rel=\"noopener\">Couchbase<\/a>\u00a0cluster (resulting in much lower TCO).<\/p><\/blockquote>\n<hr \/>\n<h2>Using Eventing for Scopes &amp; Collections Migration<\/h2>\n<p><span style=\"font-weight: 400\">In the prior article (Part 1), I discussed the mechanics of a high performance method to migrate from an older Couchbase version to Scopes and Collections in Couchbase 7.0 based on <a href=\"https:\/\/www.couchbase.com\/products\/eventing\/\">Eventing<\/a>.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Just the Data Service (or KV) and the Eventing Service is required to migrate from buckets to collections. In a well-tuned, large Couchbase cluster, you can migrate over 1 million documents a second. Yes, no N1QL, and no index needed.<\/span><\/p>\n<p><span style=\"font-weight: 400\">In this follow up article, I will provide a simple fully automated methodology to do large migrations with dozens (or even hundreds) of data types via a simple <\/span><i><span style=\"font-weight: 400\">Perl<\/span><\/i><span style=\"font-weight: 400\"> script.<\/span><\/p>\n<h3>Recap of the final\u00a0 Eventing Function: ConvertBucketToCollections<\/h3>\n<p><span style=\"font-weight: 400\">In Part 1 we had the following settings for the Eventing Function.\u00a0 Note to each unique type, &#8220;<strong>beer<\/strong>&#8221; and &#8220;<strong>brewery<\/strong>&#8221; we had to add a Bucket binding alias to the target collection in &#8220;read+write&#8221; mode.\u00a0 In addition we had to create the target collections, in this case &#8220;<strong>bulk.data.beer<\/strong>&#8221; and &#8220;<strong>bulk.data.brewery<\/strong>&#8220;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-12480 size-full\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/11\/Part2_FINAL_SETTINGS.jpg\" alt=\"\" width=\"513\" height=\"991\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/11\/Part2_FINAL_SETTINGS.jpg 513w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/11\/Part2_FINAL_SETTINGS-155x300.jpg 155w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/11\/Part2_FINAL_SETTINGS-300x580.jpg 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/11\/Part2_FINAL_SETTINGS-10x20.jpg 10w\" sizes=\"auto, (max-width: 513px) 100vw, 513px\" \/><\/p>\n<p><span style=\"font-weight: 400\">In Part 1 we had the following JavaScript code in our Eventing Function.\u00a0 Note to each unique type, &#8220;<strong>beer<\/strong>&#8221; and &#8220;<strong>brewery<\/strong>&#8221; we had to replicate a JavaScript code block and update reference the corresponding binding alias or target collection in the Couchbase Data Service.<\/span><\/p>\n<pre class=\"toolbar-overlay:false lang:js decode:true\">function OnUpdate(doc, meta) {\r\n    if (!doc.type) return;\r\n  \r\n    var type = doc.type;\r\n    if (DROP_TYPE) delete doc.type;\r\n  \r\n    if (type === 'beer') {\r\n        if (DO_COPY) beer_col[meta.id] = doc;\r\n        if (DO_DELETE) {\r\n            if(!beer_col[meta.id]) { \/\/ safety check \r\n                log(\"skip delete copy not found type=\" + doc.type + \", meta.id=\" + meta.id);\r\n            } else {\r\n                delete src_col[meta.id];\r\n            }\r\n        }\r\n    }\r\n    if (type === 'brewery') {\r\n        if (DO_COPY) brewery_col[meta.id] = doc;\r\n        if (DO_DELETE) {\r\n            if(!brewery_col[meta.id]) { \/\/ safety check\r\n                log(\"skip delete copy not found type=\" + doc.type + \", meta.id=\" + meta.id);\r\n            } else {\r\n                delete src_col[meta.id];\r\n            }\r\n        }\r\n    }\r\n}<\/pre>\n<h2>The technique in Part 1 works but what if I have a lot of types?<\/h2>\n<p>Using Eventing can indeed do migrations as shown in Part 1, but it seems like a bit of work to set things up.<\/p>\n<p>If you have 80 different types, it would be an incredible amount of error-prone effort to use this technique (both creating the Eventing Function and creating the needed keyspaces). If I had 80 types in a bucket to migrate and split, I wouldn&#8217;t want to do all the work described above by hand for each type.<\/p>\n<h2>Automate via CustomConvertBucketToCollections.pl<\/h2>\n<p>To solve this problem, I wrote a tiny <em>Perl<\/em> script, <em>CustomConvertBucketToCollections.pl<\/em>, that generates two files:<\/p>\n<ul>\n<li><em>CustomConvertBucketToCollections.json<\/em>, <span style=\"font-weight: 400\">is a complete Eventing Function which does all of the above work described in this post<\/span>.<\/li>\n<li><em>MakeCustomKeyspaces.sh<\/em>, <span style=\"font-weight: 400\">is a shell file to build all the needed keyspaces and import the generated Eventing function.<\/span><\/li>\n<\/ul>\n<p>You can find this script in GitHub at <a href=\"https:\/\/github.com\/jon-strabala\/cb-buckets-to-collections\">https:\/\/github.com\/jon-strabala\/cb-buckets-to-collections<\/a>.<\/p>\n<p>Note, the script <em>CustomConvertBucketToCollections.pl <\/em>requires that both <strong><em>Perl<\/em><\/strong> (practical extraction and report language) and also <strong><em>jq<\/em><\/strong> (a lightweight and flexible command-line JSON processor) are installed on your system.<\/p>\n<h2>Example: Migrate 250M Records with 80 Different Types<\/h2>\n<p><span style=\"font-weight: 400\">We have 250M documents in keyspac<\/span>e &#8220;<strong>input._default._default<\/strong>&#8221; with <span style=\"font-weight: 400\">80 different types and want to reorganize the data by type into collections under the <\/span>scope\u00a0 &#8220;<strong>output.reorg<\/strong>&#8221; <span style=\"font-weight: 400\">by the property type. We have an AWS cluster of three r5.2xlarge instances, all running the Data Service and the Evening Service.<\/span><\/p>\n<p>The input bucket &#8220;<strong>input<\/strong>&#8221; in this example is configured with a memory quota of 16000 MB.<\/p>\n<p>Below I use the CustomConvertBucketToCollections.pl <em>Perl<\/em> script from GitHub at <a href=\"https:\/\/github.com\/jon-strabala\/cb-buckets-to-collections\">https:\/\/github.com\/jon-strabala\/cb-buckets-to-collections<\/a>. As you can see it can be trivial to do migrations using an automated script.<\/p>\n<h3>Step 1: One-time Setup<\/h3>\n<pre class=\"toolbar-overlay:false lang:default decode:true\">git clone https:\/\/github.com\/jon-strabala\/cb-buckets-to-collections\r\ncd cb-buckets-to-collections\r\nPATH=${PATH}:\/opt\/couchbase\/bin\r\n\r\ncd cb-buckets-to-collections\/\r\nchmod +x CustomConvertBucketToCollections.pl big_data_test_gen.pl big_data_test_load.sh<\/pre>\n<h3>Step 2: Create 250M test documents<\/h3>\n<p>Running the interactive <strong>big_data_test_load.sh<\/strong>\u00a0command:<\/p>\n<pre class=\"toolbar-overlay:false lang:default decode:true\">.\/big_data_test_load.sh<\/pre>\n<p>Input configuration parameters:<\/p>\n<pre># This bash script, 'big_data_test_load.sh', will load &lt;N&gt; million test\r\n# documents into a &lt;bucket&gt;._default._default in 1 million chunks as\r\n# created by the perl script 'big_data_test_gen.pl'. The data will\r\n# have 80 different document type values evenly distributed.\r\n\r\nEnter the number of test docs to create in the millions    250\r\nEnter the bucket (or target) to load test docs into        input\r\nEnter the username:password to your cluster                admin:jtester\r\nEnter the hostname or ip address of your cluster           localhost\r\nEnter the number of threads for cbimport                   8\r\n\r\nWill load 2 million test docs into keyspace input._default._default (the default for bucket input)\r\ntype ^C to abort, running in 5 sec.\r\n\r\nRunning ....\r\ngen\/cbimport block: 1 of 2, start at Mon 01 Nov 2021 11:06:01 AM PDT\r\nJSON `file:\/\/.\/data.json` imported to `couchbase:\/\/localhost` successfully\r\nDocuments imported: 1000000 Documents failed: 0\r\n** removed 23 lines **\r\ngen\/cbimport block: 250 of 250, start at Mon 01 Nov 2021 11:24:05 AM PDT\r\nJSON `file:\/\/.\/data.json` imported to `couchbase:\/\/localhost` successfully\r\nDocuments imported: 1000000 Documents failed: 0<\/pre>\n<p>There should now be 250M test documents in the keyspace\u00a0<strong>input._default._default<\/strong>.<\/p>\n<h3>Step 3: Generate Eventing Function and Keyspace script<\/h3>\n<p>Running the interactive\u00a0<strong>CustomConvertBucketToCollections.pl<\/strong>\u00a0command:<\/p>\n<pre class=\"toolbar-overlay:false lang:default decode:true\">.\/CustomConvertBucketToCollections.pl<\/pre>\n<p>Input configuration parameters:<\/p>\n<pre class=\"toolbar-overlay:false copy:false lang:default decode:true\">Enter the bucket (or source) to convert to collections [travel-sample]: input\r\nEnter the username:password to your cluster [admin:jtester]:\r\nEnter the hostname or ip address of your cluster [localhost]:\r\nEnter the destination bucket.scope [mybucket.myscope]: output.reorg\r\nEnter the Eventing storage keyspace bucket.scope.collection [rr100.eventing.metadata]:\r\nEnter the number of workers (LTE # cores more is faster) [8]:\r\nProbe the bucket (or source) to determine the set of types [Y]:\r\nsamples across the bucket (or source) to find types [20000]: 100000\r\nmaximum estimated # of types in the bucket (or source) [30]: 100\r\n\r\n\r\nScanning input for 'type' property this may take a few seconds\r\n\r\ncurl -s -u Administrator:password https:\/\/localhost:8093\/query\/service -d \\\r\n    'statement=INFER `input`._default._default WITH {\"sample_size\": 100000, \"num_sample_values\": 100, \"similarity_metric\": 0.1}' \\\r\n    | jq '.results[][].properties.type.samples | .[]' | sort -u\r\n\r\nTYPES FOUND: t01 t02 t03 t04 t05 t06 t07 t08 t09 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25 t26 t27 t28 t29 \r\nt30 t31 t32 t33 t34 t35 t36 t37 t38 t39 t40 t41 t42 t43 t44 t45 t46 t47 t48 t49 t50 t51 t52 t53 t54 t55 t56 t57 t58 t59 t60 t61 \r\nt62 t63 t64 t65 t66 t67 t68 t69 t70 t71 t72 t73 t74 t75 t76 t77 t78 t79 t80\r\n\r\nGenerating Eventing Function: CustomConvertBucketToCollections.json\r\n\r\nGenerating Keyspace commands: MakeCustomKeyspaces.sh<\/pre>\n<p><span style=\"font-weight: 400\">In the interactive <\/span><i><span style=\"font-weight: 400\">Perl<\/span><\/i><span style=\"font-weight: 400\"> script above, four of the above default choices were altered.<\/span><\/p>\n<h3>Step 3: Update the MakeCustomKeyspaces.sh (as needed)<\/h3>\n<p><span style=\"font-weight: 400\">You can just &#8220;<strong>vi MakeCustomKeyspaces.sh<\/strong>&#8221; and alter any needed values. I choose to use the Unix <\/span><i><span style=\"font-weight: 400\">sed<\/span><\/i><span style=\"font-weight: 400\"> command to increase the RAM size of the <\/span>bucket &#8220;<strong>output&#8221;<\/strong> from 100 to 1600<\/p>\n<pre class=\"toolbar-overlay:false lang:default decode:true\">cat MakeCustomKeyspaces.sh | sed -e 's\/\\(^.*bucket=output.*ramsize=\\)100 \\(\\.*\\)\/\\116000 \\2\/' &gt; tmp\r\nmv tmp MakeCustomKeyspaces.sh<\/pre>\n<h3>Step 4: Run the MakeCustomKeyspaces.sh script<\/h3>\n<pre class=\"toolbar-overlay:false lang:default decode:true\">sh .\/MakeCustomKeyspaces.sh<\/pre>\n<p class=\"\">output below:<\/p>\n<pre class=\"copy:false lang:default decode:true \">SUCCESS: Bucket created\r\nSUCCESS: Scope created\r\nSUCCESS: Collection created\r\nSUCCESS: Bucket created\r\nSUCCESS: Scope created\r\nSUCCESS: Collection created\r\nSUCCESS: Collection created\r\n** removed 77 lines **\r\nSUCCESS: Collection created\r\nSUCCESS: Events imported<\/pre>\n<h3>Step 5: Refresh your Couchbase UI on the Eventing Page<\/h3>\n<p>To find the new Eventing Function (or updated Function) in the Couchbase UI, go to the Eventing Page and refresh your web browser.<\/p>\n<h3>Step 6: Deploy CustomConvertBucketToCollections<\/h3>\n<p>In the Couchbase UI, go to the Eventing Page and deploy the Eventing Function &#8220;<strong>CustomConvertBucketToCollections<\/strong>&#8220;.<\/p>\n<p>In about 45 minutes the reorganization should be completely done.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12180\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/10\/04_in_done_a.jpg\" alt=\"\" width=\"1073\" height=\"711\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/04_in_done_a.jpg 1073w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/04_in_done_a-300x199.jpg 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/04_in_done_a-1024x679.jpg 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/04_in_done_a-768x509.jpg 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/04_in_done_a-20x13.jpg 20w\" sizes=\"auto, (max-width: 1073px) 100vw, 1073px\" \/><\/p>\n<p>All the documents are indeed reorganized by type as collections. On this modest cluster, they were processed at 93K docs\/sec.<\/p>\n<h2>Final Thoughts<\/h2>\n<p>If you found this article series helpful and are interested in continuing to learn about eventing &#8211; click here <a href=\"https:\/\/www.couchbase.com\/products\/eventing\/?ref=blog\" target=\"_blank\" rel=\"noopener\">the Couchbase Eventing Service<\/a>.<\/p>\n<p>I hope you find the CustomConvertBucketToCollections.pl <em>Perl<\/em> script from GitHub at <a href=\"https:\/\/github.com\/jon-strabala\/cb-buckets-to-collections\">https:\/\/github.com\/jon-strabala\/cb-buckets-to-collections<\/a> a valuable tool in your arsenal when you need to migrate a bucket with many types into a collections paradigm.<\/p>\n<p>Feel free to improve the CustomConvertBucketToCollections.pl script to use an intermediate config file to the Eventing <em>Perl<\/em> tool where all the parameters could be adjusted. Then use the intermediate config file to create the Eventing Function and the setup shell script.<\/p>\n<p>Example intermediate config file:<\/p>\n<pre class=\"\">[\r\n  {\r\n\t\"src_ks\": \"input._default._default\",\r\n\t\"dst_ks\": \"output.myscope.t01\",\r\n\t\"create_dst_ks\": true,\r\n\t\"dst_copy\": true,\r\n\t\"src_del\": true,\r\n\t\"dst_remove_type\": true\r\n  }, {\r\n\t\"src_ks\": \"input._default._default\",\r\n\t\"dst_ks\": \"output.myscope.t02\",\r\n\t\"create_dst_ks\": true,\r\n\t\"dst_copy\": true,\r\n\t\"src_del\": true,\r\n\t\"dst_remove_type\": true\r\n  }, {\r\n\t\"src_ks\": \"input._default._default\",\r\n\t\"dst_ks\": \"output.myscope.t03\",\r\n\t\"create_dst_ks\": true,\r\n\t\"dst_copy\": true,\r\n\t\"src_del\": true,\r\n\t\"dst_remove_type\": true\r\n  }\r\n]<\/pre>\n<h2>Resources<\/h2>\n<ul>\n<li><em>Download:<\/em> <a href=\"https:\/\/couchbase.com\/downloads\/?ref=blog\" target=\"_blank\" rel=\"noopener\">Download Couchbase Server 7.0<\/a><\/li>\n<li><i><span style=\"font-weight: 400\">Eventing Scriptlet:<\/span><\/i><a href=\"https:\/\/docs.couchbase.com\/server\/current\/eventing\/eventing-handler-ConvertBucketToCollections.html?ref=blog\"> <span style=\"font-weight: 400\">Function: ConvertBucketToCollections<\/span><\/a><\/li>\n<li><em>GitHub:<\/em> <a href=\"https:\/\/github.com\/jon-strabala\/cb-buckets-to-collections?ref=blog\" target=\"_blank\" rel=\"noopener\">Perl Tool: cb-buckets-to-collections.pl<\/a><\/li>\n<\/ul>\n<h2>References<\/h2>\n<ul>\n<li><a href=\"https:\/\/docs.couchbase.com\/server\/6.6\/eventing\/eventing-overview.html?ref=blog\" target=\"_blank\" rel=\"noopener noreferrer\">Couchbase Eventing documentation<\/a><\/li>\n<li><a href=\"https:\/\/docs.couchbase.com\/server\/7.0\/introduction\/whats-new.html?ref=blog\" target=\"_blank\" rel=\"noopener noreferrer\">What&#8217;s New: Couchbase Server 7.0<\/a><\/li>\n<li><a href=\"https:\/\/www.couchbase.com\/blog\/how-to-migrate-to-scopes-and-collections-in-couchbase-7-0\/\" target=\"_blank\" rel=\"noopener\">How to Migrate to Scopes &amp; Collections in Couchbase 7.0<\/a><\/li>\n<li><a href=\"https:\/\/www.couchbase.com\/blog\/tag\/eventing\/?ref=blog\" target=\"_blank\" rel=\"noopener noreferrer\">Other Couchbase blogs on Eventing<\/a><\/li>\n<\/ul>\n<p>I would love to hear from you on how you liked the capabilities of Couchbase and the Eventing service, and how they benefit your business going forward. Please share your feedback via the comments below or in <a href=\"https:\/\/www.couchbase.com\/forums\/?ref=blog\" target=\"_blank\" rel=\"noopener\">the Couchbase forums<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Migrating Buckets to Collections &amp; Scopes via Eventing: Part 2 Again (as I did in Part 1) I want to point out an excellent blog written by Shivani Gupta, How to Migrate to Scopes &amp; Collections in Couchbase 7.0, which [&hellip;]<\/p>\n","protected":false},"author":42711,"featured_media":12478,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1815,1821,1816,2273,9336],"tags":[2379,9343,1766,9339],"ppma_author":[9113],"class_list":["post-12479","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-best-practices-and-tutorials","category-couchbase-architecture","category-couchbase-server","category-eventing","category-scopes-and-collections","tag-best-practices","tag-couchbase-7-0","tag-data-migration","tag-scopes-and-collections"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.7.1 (Yoast SEO v25.7) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Migrating Buckets to Collections &amp; Scopes via Eventing: Part 2 - The Couchbase Blog<\/title>\n<meta name=\"description\" content=\"Learn how to use the Couchbase Eventing Service to easily and automatically migrate your Bucket based data to Scopes &amp; Collections. Part 2\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Migrating Buckets to Collections &amp; Scopes via Eventing: Part 2\" \/>\n<meta property=\"og:description\" content=\"Learn how to use the Couchbase Eventing Service to easily and automatically migrate your Bucket based data to Scopes &amp; Collections. Part 2\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2021-12-21T16:00:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T05:40:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/11\/migration2-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1600\" \/>\n\t<meta property=\"og:image:height\" content=\"799\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jon Strabala, Principal Product Manager, Couchbase\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jon Strabala, Principal Product Manager, Couchbase\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/\"},\"author\":{\"name\":\"Jon Strabala, Principal Product Manager, Couchbase\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c991579f88217edee79ffedb6fc914cc\"},\"headline\":\"Migrating Buckets to Collections &amp; Scopes via Eventing: Part 2\",\"datePublished\":\"2021-12-21T16:00:29+00:00\",\"dateModified\":\"2025-06-14T05:40:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/\"},\"wordCount\":1058,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/11\/migration2-1.jpg\",\"keywords\":[\"best practices\",\"Couchbase 7.0\",\"Data Migration\",\"Scopes and Collections\"],\"articleSection\":[\"Best Practices and Tutorials\",\"Couchbase Architecture\",\"Couchbase Server\",\"Eventing\",\"Scopes and Collections\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/\",\"name\":\"Migrating Buckets to Collections &amp; Scopes via Eventing: Part 2 - The Couchbase Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/11\/migration2-1.jpg\",\"datePublished\":\"2021-12-21T16:00:29+00:00\",\"dateModified\":\"2025-06-14T05:40:20+00:00\",\"description\":\"Learn how to use the Couchbase Eventing Service to easily and automatically migrate your Bucket based data to Scopes & Collections. Part 2\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/11\/migration2-1.jpg\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/11\/migration2-1.jpg\",\"width\":1600,\"height\":799},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Migrating Buckets to Collections &amp; Scopes via Eventing: Part 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c991579f88217edee79ffedb6fc914cc\",\"name\":\"Jon Strabala, Principal Product Manager, Couchbase\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/9c6045b0c2f7b07b0ee10f94ad748a25\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/db52a9f6d84faba430dd38106cdbc16ff02c2066b103b5f6b4cfcde40e83c683?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/db52a9f6d84faba430dd38106cdbc16ff02c2066b103b5f6b4cfcde40e83c683?s=96&d=mm&r=g\",\"caption\":\"Jon Strabala, Principal Product Manager, Couchbase\"},\"description\":\"Jon Strabala is a Principal Product Manager, responsible for the Couchbase Eventing Service. Before joining Couchbase, he spent more than 20 years building software products across various domains, starting with EDA in aerospace then transitioning to building enterprise software focused on what today is coined \u201cIoT\u201d and \u201cat-scale data.\u201d Jon worked for several small software consultancies until eventually starting and managing his own firm. He has extensive experience in NoSQL\/NewSQL, both in contributing and commercializing new technologies such as compressed bitmaps and column stores. Jon holds a bachelor\u2019s degree in electrical engineering and a master's in computer engineering, both from the University of Southern California, and an MBA from the University of California at Irvine.\",\"url\":\"https:\/\/www.couchbase.com\/blog\/author\/jon-strabala\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Migrating Buckets to Collections &amp; Scopes via Eventing: Part 2 - The Couchbase Blog","description":"Learn how to use the Couchbase Eventing Service to easily and automatically migrate your Bucket based data to Scopes & Collections. Part 2","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/","og_locale":"en_US","og_type":"article","og_title":"Migrating Buckets to Collections &amp; Scopes via Eventing: Part 2","og_description":"Learn how to use the Couchbase Eventing Service to easily and automatically migrate your Bucket based data to Scopes & Collections. Part 2","og_url":"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/","og_site_name":"The Couchbase Blog","article_published_time":"2021-12-21T16:00:29+00:00","article_modified_time":"2025-06-14T05:40:20+00:00","og_image":[{"width":1600,"height":799,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/11\/migration2-1.jpg","type":"image\/jpeg"}],"author":"Jon Strabala, Principal Product Manager, Couchbase","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Jon Strabala, Principal Product Manager, Couchbase","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/"},"author":{"name":"Jon Strabala, Principal Product Manager, Couchbase","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c991579f88217edee79ffedb6fc914cc"},"headline":"Migrating Buckets to Collections &amp; Scopes via Eventing: Part 2","datePublished":"2021-12-21T16:00:29+00:00","dateModified":"2025-06-14T05:40:20+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/"},"wordCount":1058,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/11\/migration2-1.jpg","keywords":["best practices","Couchbase 7.0","Data Migration","Scopes and Collections"],"articleSection":["Best Practices and Tutorials","Couchbase Architecture","Couchbase Server","Eventing","Scopes and Collections"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/","url":"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/","name":"Migrating Buckets to Collections &amp; Scopes via Eventing: Part 2 - The Couchbase Blog","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/11\/migration2-1.jpg","datePublished":"2021-12-21T16:00:29+00:00","dateModified":"2025-06-14T05:40:20+00:00","description":"Learn how to use the Couchbase Eventing Service to easily and automatically migrate your Bucket based data to Scopes & Collections. Part 2","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/11\/migration2-1.jpg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/11\/migration2-1.jpg","width":1600,"height":799},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Migrating Buckets to Collections &amp; Scopes via Eventing: Part 2"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"The Couchbase Blog","description":"Couchbase, the NoSQL Database","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c991579f88217edee79ffedb6fc914cc","name":"Jon Strabala, Principal Product Manager, Couchbase","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/9c6045b0c2f7b07b0ee10f94ad748a25","url":"https:\/\/secure.gravatar.com\/avatar\/db52a9f6d84faba430dd38106cdbc16ff02c2066b103b5f6b4cfcde40e83c683?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/db52a9f6d84faba430dd38106cdbc16ff02c2066b103b5f6b4cfcde40e83c683?s=96&d=mm&r=g","caption":"Jon Strabala, Principal Product Manager, Couchbase"},"description":"Jon Strabala is a Principal Product Manager, responsible for the Couchbase Eventing Service. Before joining Couchbase, he spent more than 20 years building software products across various domains, starting with EDA in aerospace then transitioning to building enterprise software focused on what today is coined \u201cIoT\u201d and \u201cat-scale data.\u201d Jon worked for several small software consultancies until eventually starting and managing his own firm. He has extensive experience in NoSQL\/NewSQL, both in contributing and commercializing new technologies such as compressed bitmaps and column stores. Jon holds a bachelor\u2019s degree in electrical engineering and a master's in computer engineering, both from the University of Southern California, and an MBA from the University of California at Irvine.","url":"https:\/\/www.couchbase.com\/blog\/author\/jon-strabala\/"}]}},"authors":[{"term_id":9113,"user_id":42711,"is_guest":0,"slug":"jon-strabala","display_name":"Jon Strabala, Principal Product Manager, Couchbase","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/db52a9f6d84faba430dd38106cdbc16ff02c2066b103b5f6b4cfcde40e83c683?s=96&d=mm&r=g","author_category":"","last_name":"Strabala, Principal Product Manager, Couchbase","first_name":"Jon","job_title":"","user_url":"","description":"Jon Strabala is a Principal Product Manager, responsible for the Couchbase Eventing Service. Before joining Couchbase, he spent more than 20 years building software products across various domains, starting with EDA in aerospace then transitioning to building enterprise software focused on what today is coined \u201cIoT\u201d and \u201cat-scale data.\u201d Jon worked for several small software consultancies until eventually starting and managing his own firm. He has extensive experience in NoSQL\/NewSQL, both in contributing and commercializing new technologies such as compressed bitmaps and column stores. Jon holds a bachelor\u2019s degree in electrical engineering and a master's in computer engineering, both from the University of Southern California, and an MBA from the University of California at Irvine."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/12479","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/users\/42711"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=12479"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/12479\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/12478"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=12479"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=12479"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=12479"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=12479"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}