{"id":12476,"date":"2021-12-20T08:00:41","date_gmt":"2021-12-20T16:00:41","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=12476"},"modified":"2025-06-13T22:40:20","modified_gmt":"2025-06-14T05:40:20","slug":"migrating-buckets-to-collections-scopes-via-eventing-part-1","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-1\/","title":{"rendered":"Migrating Buckets to Collections &amp; Scopes via Eventing: Part 1"},"content":{"rendered":"<h2>Migrating Buckets to Collections &amp; Scopes via Eventing: Part 1<\/h2>\n<p>First 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>In this article, I\u2019ll discuss the mechanics of another high performance method to migrate from an older Couchbase version to Scopes and Collections in Couchbase 7.0.<\/p>\n<p>You only need the Data Service (or KV) and Eventing 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.<\/p>\n<p>In the follow up post (Part 2), I will provide a simple fully automated methodology to do large migrations with dozens <span style=\"font-weight: 400\">\u00a0(or even hundreds) <\/span>of data types via a simple <em>Perl<\/em> script.<\/p>\n<h2 id=\"prereq\">Prerequisites: Learning about Eventing<\/h2>\n<p><span style=\"font-weight: 400\">In this article, we will use the latest version of Couchbase (7.0.2), but prior 7.0 versions work fine as well.<\/span><\/p>\n<p>If you are not familiar with Couchbase or the Eventing service, please walk through the following resources, including at least one Eventing example:<\/p>\n<ul>\n<li><a href=\"https:\/\/docs.couchbase.com\/server\/current\/getting-started\/start-here.html?ref=blog\" target=\"_blank\" rel=\"noopener\">Setup a working Couchbase 7.0 server<\/a> as per the directions under &#8220;Start Here!&#8221;<\/li>\n<li>Understand how to deploy a basic Eventing function as <a href=\"https:\/\/docs.couchbase.com\/server\/current\/eventing\/eventing-example-data-enrichment.html?ref=blog\" target=\"_blank\" rel=\"noopener\">per the directions in the Data Enrichment example<\/a>. Look at &#8220;Case 2&#8221; where we will only use the &#8220;source&#8221; bucket:\n<ol>\n<li><span style=\"font-weight: 400\">Two buckets \u201c<\/span><b>bulk<\/b><span style=\"font-weight: 400\">\u201d and \u201c<\/span><b>rr100<\/b><span style=\"font-weight: 400\">\u201d of size 100 MB.<\/span><\/li>\n<li><span style=\"font-weight: 400\">A source keyspace \u201c<\/span><b>bulk.data.source<\/b><span style=\"font-weight: 400\">\u201d.<\/span><\/li>\n<li><span style=\"font-weight: 400\">An eventing scratchpad keyspace \u201c<\/span><b>rr100.eventing.metadata<\/b><span style=\"font-weight: 400\">\u201d.<\/span><\/li>\n<\/ol>\n<\/li>\n<li>See the documentation for <a href=\"https:\/\/docs.couchbase.com\/server\/current\/manage\/manage-buckets\/create-bucket.html?ref=blog\" target=\"_blank\" rel=\"noopener\">detailed steps on how to create a bucket<\/a>.<\/li>\n<\/ul>\n<h3>Eventing Function: ConvertBucketToCollections<\/h3>\n<p><span style=\"font-weight: 400\">Eventing allows you to write pure business logic. The Eventing service takes care of the entire infrastructure needed to manage and scale your function (horizontally and vertically) across multiple nodes in a performant and reliable fashion.<\/span><\/p>\n<p>All Eventing functions have two entry points &#8211; <code>OnUpdate(doc, meta)<\/code> and <code>OnDelete(meta, options)<\/code>. Note that we&#8217;re not worried about the latter entry point in this example.<\/p>\n<p>When a document changes or mutates (insert, upsert, replace, etc.), a copy of the document and some metadata about the document is passed to a small JavaScript entry point <code>OnUpdate(doc, meta)<\/code>.<\/p>\n<p><span style=\"font-weight: 400\">Eventing Functions can be deployed with two different Deployment Feed Boundaries, either &#8220;<strong>From now<\/strong>&#8221; or &#8220;<strong>Everything<\/strong>&#8220;. The latter allows access to every current document in a Bucket in Couchbase 6.6 or a Keyspace (Bucket\/Scope\/Collection) in Couchbase 7.0<\/span>.<\/p>\n<p>The scriptlet <a href=\"https:\/\/docs.couchbase.com\/server\/current\/eventing\/eventing-handler-ConvertBucketToCollections.html\" target=\"_blank\" rel=\"noopener\"><em>ConvertBucketToCollections<\/em><\/a> <span style=\"font-weight: 400\">from the main Eventing docs shows how to utilize Eventing to take data from a source bucket to a destination bucket and split your data into collections<\/span>.<\/p>\n<h3>Step 1: Load Sample Data<\/h3>\n<p>In the Couchbase UI, select &#8220;<strong>Settings\/Sample Buckets<\/strong>&#8220;. Check <code>beer-sample<\/code> <span style=\"font-weight: 400\">and click on the button &#8220;<strong>Load Sample Data<\/strong>&#8220;.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12168\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/10\/P0a_LOAD_SAMPLE.jpg\" alt=\"\" width=\"850\" height=\"349\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P0a_LOAD_SAMPLE.jpg 850w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P0a_LOAD_SAMPLE-300x123.jpg 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P0a_LOAD_SAMPLE-768x315.jpg 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P0a_LOAD_SAMPLE-20x8.jpg 20w\" sizes=\"auto, (max-width: 850px) 100vw, 850px\" \/><\/p>\n<h3>Step 2: Make the Needed Keyspaces<\/h3>\n<p>This example requires three buckets: &#8220;<strong>beer-sample&#8221;<\/strong> (i.e., your document store to migrate), &#8220;<b>rr100&#8243; <\/b>(i.e., a scratchpad for Eventing that can be shared with other Eventing functions) and <strong>bulk<\/strong> (the bucket to create your migrated collections in). The &#8220;<b>rr100&#8243;<\/b> and &#8220;<strong>bulk&#8221;<\/strong> bucket should have a minimum size of 100MB.<\/p>\n<p>In the Couchbase UI, select &#8220;<strong>Buckets<\/strong>&#8221; and hit the &#8220;<strong>ADD BUCKET<\/strong>&#8221; link in the upper right.<\/p>\n<p>Create two Buckets with size 100 MB, &#8220;<strong>rr100<\/strong>&#8221; (for the Eventing storage or scratch pad) and &#8220;<strong>bulk<\/strong>&#8221; (for the migration target).<\/p>\n<p>In Bucket &#8220;<strong>rr100&#8243; <\/strong>create scope &#8220;<strong>eventing<\/strong>&#8220;.<\/p>\n<p>In the Scope &#8220;<strong>rr100.<\/strong><strong>eventing<\/strong>&#8221; create the collection &#8220;<strong>metadata<\/strong>&#8220;.<\/p>\n<p>In Bucket &#8220;<strong>bulk<\/strong>&#8221; create scope &#8220;<strong>data<\/strong>&#8220;.<\/p>\n<p>In the Scope &#8220;<strong>bulk.data<\/strong>&#8221; create the collections &#8220;<strong>beer<\/strong>&#8221; and &#8220;<strong>brewery<\/strong>&#8220;.<\/p>\n<p>At this point you should have three (3) buckets as follows:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12170\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/10\/P3_BUCKETS.jpg\" alt=\"\" width=\"831\" height=\"312\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P3_BUCKETS.jpg 831w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P3_BUCKETS-300x113.jpg 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P3_BUCKETS-768x288.jpg 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P3_BUCKETS-20x8.jpg 20w\" sizes=\"auto, (max-width: 831px) 100vw, 831px\" \/><\/p>\n<p>with the following collections in the &#8220;<strong>bulk&#8221;<\/strong> bucket:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12172\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/10\/P3a_BUCKET_bulk.jpg\" alt=\"\" width=\"831\" height=\"328\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P3a_BUCKET_bulk.jpg 831w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P3a_BUCKET_bulk-300x118.jpg 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P3a_BUCKET_bulk-768x303.jpg 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P3a_BUCKET_bulk-20x8.jpg 20w\" sizes=\"auto, (max-width: 831px) 100vw, 831px\" \/><\/p>\n<p>and the following collections in the &#8220;<b>rr100&#8243; <\/b>bucket:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12171\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/10\/P3a_BUCKET_rr100.jpg\" alt=\"\" width=\"830\" height=\"312\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P3a_BUCKET_rr100.jpg 830w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P3a_BUCKET_rr100-300x113.jpg 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P3a_BUCKET_rr100-768x289.jpg 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P3a_BUCKET_rr100-20x8.jpg 20w\" sizes=\"auto, (max-width: 830px) 100vw, 830px\" \/><\/p>\n<h3>Step 3: Create the Eventing Function<\/h3>\n<p>In the Couchbase UI, select &#8220;<strong>Eventing<\/strong>&#8221; and hit the &#8220;<strong>ADD FUNCTION<\/strong>&#8221; link in the upper right.<\/p>\n<p>The settings for the Eventing Function are as follows:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12167\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/10\/P1_SIMPLE_SETTINGS.jpg\" alt=\"\" width=\"516\" height=\"940\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P1_SIMPLE_SETTINGS.jpg 516w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P1_SIMPLE_SETTINGS-165x300.jpg 165w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P1_SIMPLE_SETTINGS-300x547.jpg 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P1_SIMPLE_SETTINGS-11x20.jpg 11w\" sizes=\"auto, (max-width: 516px) 100vw, 516px\" \/><\/p>\n<p>Hit the button &#8220;<strong>Save<\/strong>&#8221; then paste this script in the Function Editor panel:<\/p>\n<pre class=\"toolbar-overlay:false lang:default decode:true\">function OnUpdate(doc, meta) { \r\n    if (doc.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 (doc.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<p>Your code editor should look like:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12169\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/10\/P2_SAVE_FUNC.jpg\" alt=\"\" width=\"831\" height=\"599\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P2_SAVE_FUNC.jpg 831w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P2_SAVE_FUNC-300x216.jpg 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P2_SAVE_FUNC-768x554.jpg 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P2_SAVE_FUNC-20x14.jpg 20w\" sizes=\"auto, (max-width: 831px) 100vw, 831px\" \/><\/p>\n<p>Hit the button &#8220;<strong>Save and Return<\/strong>&#8221;<\/p>\n<h3>What the ConvertBucketToCollections does<\/h3>\n<p>The <code>OnUpdate(doc, meta)<\/code> logic will process all data in the <strong>`beer-sample`._default._default<\/strong> keyspace and will perform the following on any past (historical) and any new (future) mutations.<\/p>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li>First, the property of the <em><span class=\"pl-s1\">doc<\/span><span class=\"pl-kos\">.<\/span><span class=\"pl-c1\">type <\/span><\/em>is checked in two near identical code blocks to see if it matches either <code>beer<\/code>, or <code>brewery<\/code><span style=\"font-weight: 400\">. If there\u2019s a match, continue.<\/span><\/li>\n<li>A global constant <code>DO_COPY<\/code> (provided via the Functions settings via a Constant Binding alias) is checked to see if the item should be copied.<\/li>\n<li>If <code>DO_COPY<\/code> is true, the document will be written to target collection or keyspace <code>beer_col<\/code> or <code>brewery_col<\/code> (defined via the Functions settings via a Bucket Binding alias) depending on the code block that matched.<\/li>\n<li>A global constant <code>DO_DELETE<\/code> (provided via the Functions settings via a Constant Binding alias) is checked to see if the item should be removed from the source keyspace or collection (defined via the Functions settings via a Bucket Binding alias)<\/li>\n<li>If <code>DO_DELETE<\/code> is true, the document will be removed from the collection or keyspace <code>src_col<\/code> (defined via the Functions settings via a Bucket Binding alias).<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>We could increase the workers from 1 to the number of vCPUs for better performance, but our dataset is trivial so we just leave the worker count as one (1). <em>Note: The setting for workers is found in the expandable section Settings in the middle of the Function Settings dialog<\/em>.<\/p>\n<h2>Deploying the Eventing Function<\/h2>\n<p>Now it&#8217;s time to deploy the Eventing function. We&#8217;ve reviewed a bit of the code and the design of the ConvertBucketToCollections migration script, and now it&#8217;s time to see everything working together.<\/p>\n<p>At this point, we have a function in JavaScript so we need to <span style=\"font-weight: 400\">add it to our <\/span>Couchbase cluster and deploy it into an active state.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12173\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/10\/P4_deploy.jpg\" alt=\"\" width=\"831\" height=\"229\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P4_deploy.jpg 831w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P4_deploy-300x83.jpg 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P4_deploy-768x212.jpg 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P4_deploy-20x6.jpg 20w\" sizes=\"auto, (max-width: 831px) 100vw, 831px\" \/><\/p>\n<p>Hit the button &#8220;<strong>Deploy<\/strong>&#8220;.<\/p>\n<p>The Eventing Service takes about 18 seconds to deploy your Eventing Function, at which point you should immediately see 7303 items processed. Since the dataset is static, you are finish as all items have been processed. Since the dataset is static, you are finished as all items have been processed.<\/p>\n<div aria-hidden=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12174\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/10\/P5_deployed.jpg\" alt=\"\" width=\"831\" height=\"285\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P5_deployed.jpg 831w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P5_deployed-300x103.jpg 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P5_deployed-768x263.jpg 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P5_deployed-20x7.jpg 20w\" sizes=\"auto, (max-width: 831px) 100vw, 831px\" \/><\/div>\n<p>&nbsp;<\/p>\n<p>Hit the button &#8220;<strong>Undeploy<\/strong>&#8220;.<\/p>\n<h2>Looking at the Migrated Data<\/h2>\n<p>Now that we are done using the Eventing Function, we can inspect the Buckets and Collections to see what happened.<\/p>\n<p>In the Couchbase UI, select &#8220;<strong>Buckets<\/strong>&#8221;<\/p>\n<div aria-hidden=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12176\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/10\/P6_mig_buckets.jpg\" alt=\"\" width=\"833\" height=\"264\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P6_mig_buckets.jpg 833w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P6_mig_buckets-300x95.jpg 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P6_mig_buckets-768x243.jpg 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P6_mig_buckets-20x6.jpg 20w\" sizes=\"auto, (max-width: 833px) 100vw, 833px\" \/><\/div>\n<p>Now select &#8220;Scopes &amp; Collections&#8221; for the bucket &#8220;<strong>bulk&#8221;<\/strong>, then expand the scope &#8220;<strong>data&#8221;<\/strong>.<\/p>\n<div aria-hidden=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12175\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/10\/P6_mig_buckets_exp.jpg\" alt=\"\" width=\"830\" height=\"415\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P6_mig_buckets_exp.jpg 830w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P6_mig_buckets_exp-300x150.jpg 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P6_mig_buckets_exp-768x384.jpg 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P6_mig_buckets_exp-20x10.jpg 20w\" sizes=\"auto, (max-width: 830px) 100vw, 830px\" \/><\/div>\n<p>In the Couchbase UI, select &#8220;<strong>Documents<\/strong>&#8220;, then select the Keyspace &#8220;<strong>bulk.data.beer<\/strong>&#8221; and you will see the migrated documents in that collection.<\/p>\n<div aria-hidden=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12177\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/10\/P6_mig_buckets_data_beer.jpg\" alt=\"\" width=\"828\" height=\"551\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P6_mig_buckets_data_beer.jpg 828w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P6_mig_buckets_data_beer-300x200.jpg 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P6_mig_buckets_data_beer-768x511.jpg 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P6_mig_buckets_data_beer-400x267.jpg 400w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P6_mig_buckets_data_beer-450x300.jpg 450w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P6_mig_buckets_data_beer-20x13.jpg 20w\" sizes=\"auto, (max-width: 828px) 100vw, 828px\" \/><\/div>\n<p>In the Couchbase UI, select &#8220;<strong>Documents<\/strong>&#8220;, then select the Keyspace &#8220;<strong>bulk.data.brewery<\/strong>&#8221; and you will see the migrated documents in that collection.<\/p>\n<div aria-hidden=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12178\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/10\/P6_mig_buckets_data_brewery.jpg\" alt=\"\" width=\"828\" height=\"525\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P6_mig_buckets_data_brewery.jpg 828w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P6_mig_buckets_data_brewery-300x190.jpg 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P6_mig_buckets_data_brewery-768x487.jpg 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P6_mig_buckets_data_brewery-20x13.jpg 20w\" sizes=\"auto, (max-width: 828px) 100vw, 828px\" \/><\/div>\n<p>&nbsp;<\/p>\n<h3>Let&#8217;s Improve the Eventing Function<\/h3>\n<p>Remember, Eventing can enrich data on the fly, and if we are truly splitting up a bucket (circa Couchbase 6.x) into separate collections (circa Couchbase 7.0), we no longer need the<strong> type<\/strong> property.\u00a0 So let&#8217;s modify our Function to transform our data, too.<\/p>\n<p><span style=\"font-weight: 400\">For example, given the document with key &#8220;<\/span><b>abhi_brewery<\/b><span style=\"font-weight: 400\">&#8221; in our source data<\/span> in <strong>`beer-sample`._default._default<\/strong>:<\/p>\n<pre class=\"toolbar-overlay:false lang:js decode:true\">{\r\n  \"name\": \"Abhi Brewery\",\r\n  \"city\": \"\",\r\n  \"state\": \"\",\r\n  \"code\": \"\",\r\n  \"country\": \"India\",\r\n  \"phone\": \"\",\r\n  \"website\": \"\",\r\n  \"type\": \"brewery\",\r\n  \"updated\": \"2011-09-27 00:35:48\",\r\n  \"description\": \"\",\r\n  \"address\": []\r\n}\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><span style=\"font-weight: 400\">We removed<\/span>\u00a0<code>\"type\": \"brewery\"<\/code>:<\/div>\n<div aria-hidden=\"true\"><\/div>\n<div aria-hidden=\"true\">\n<pre class=\"toolbar-overlay:false lang:js decode:true\">{\r\n  \"name\": \"Abhi Brewery\",\r\n  \"city\": \"\",\r\n  \"state\": \"\",\r\n  \"code\": \"\",\r\n  \"country\": \"India\",\r\n  \"phone\": \"\",\r\n  \"website\": \"\",\r\n  \"updated\": \"2011-09-27 00:35:48\",\r\n  \"description\": \"\",\r\n  \"address\": []\r\n}\r\n<\/pre>\n<\/div>\n<p>Here&#8217;s the modification to our Eventing Function:<\/p>\n<pre class=\"toolbar-overlay:false lang:default 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<p>And since we add one new global constant <code>DROP_TYPE<\/code>, we also modify the settings as follows:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12179\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/10\/P7_drop_type.jpg\" alt=\"\" width=\"516\" height=\"220\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P7_drop_type.jpg 516w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P7_drop_type-300x128.jpg 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/P7_drop_type-20x9.jpg 20w\" sizes=\"auto, (max-width: 516px) 100vw, 516px\" \/><\/p>\n<h2>Final Thoughts<\/h2>\n<p>If you found this article 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>Now that you understand the mechanics of using Eventing to migrate your buckets to scopes and collections, please explore the follow up post (Part 2), where I provide a simple fully automated methodology to do large migrations with dozens of data types via a simple <em>Perl<\/em> script.<\/p>\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<\/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 1 First I want to point out an excellent blog written by Shivani Gupta, How to Migrate to Scopes &amp; Collections in Couchbase 7.0, which covers in great detail other methods [&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,9339],"ppma_author":[9113],"class_list":["post-12476","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-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 1 - 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 1\" \/>\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-1\/\" \/>\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 1\" \/>\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 1\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-1\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2021-12-20T16:00:41+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=\"9 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-1\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-1\/\"},\"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 1\",\"datePublished\":\"2021-12-20T16:00:41+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-1\/\"},\"wordCount\":1449,\"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-1\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/11\/migration2-1.jpg\",\"keywords\":[\"best practices\",\"Couchbase 7.0\",\"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-1\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-1\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-1\/\",\"name\":\"Migrating Buckets to Collections &amp; Scopes via Eventing: Part 1 - 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-1\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-1\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/11\/migration2-1.jpg\",\"datePublished\":\"2021-12-20T16:00:41+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 1\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-1\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-1\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-1\/#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-1\/#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 1\"}]},{\"@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 1 - 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 1","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-1\/","og_locale":"en_US","og_type":"article","og_title":"Migrating Buckets to Collections &amp; Scopes via Eventing: Part 1","og_description":"Learn how to use the Couchbase Eventing Service to easily and automatically migrate your Bucket based data to Scopes & Collections. Part 1","og_url":"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-1\/","og_site_name":"The Couchbase Blog","article_published_time":"2021-12-20T16:00:41+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":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-1\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-1\/"},"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 1","datePublished":"2021-12-20T16:00:41+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-1\/"},"wordCount":1449,"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-1\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/11\/migration2-1.jpg","keywords":["best practices","Couchbase 7.0","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-1\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-1\/","url":"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-1\/","name":"Migrating Buckets to Collections &amp; Scopes via Eventing: Part 1 - 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-1\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-1\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/11\/migration2-1.jpg","datePublished":"2021-12-20T16:00:41+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 1","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-1\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-1\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/migrating-buckets-to-collections-scopes-via-eventing-part-1\/#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-1\/#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 1"}]},{"@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\/12476","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=12476"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/12476\/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=12476"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=12476"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=12476"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=12476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}