Migrating Buckets to Collections & Scopes via Eventing

Hi,

I am migrating my Couchbase from version 6.6.0 to 7.6.1 and Sync Gateway from 2.8 to 3.1.6.

Here are a few questions:

We have imported the data to 7.6.1, and we have written a function in Eventing to move data from the default collection to another collection based on the document type.

In the latest collection, we are missing the _sync properties. I have used the reference below to move/copy the data to different collections:

Now, my questions are:

  1. Can I use a similar sync_json config for the sync function? I have tried, but I am facing issues.

json

Copy code

{
    "bootstrap": {
        "server": "couchbase://url",
        "username": "username",
        "password": "password",
        "use_tls_server": false
    },
    "bucket_credentials": {
        "mybucket": {
            "username": "username",
            "password": "password"
        }
    }
}

I am using the above config in the sync function. I had to use this curl command with the curl --location -g --request POST flag to create Sync Gateway users/sync function. When I try to configure it in the Sync Gateway JSON file, I face issues. (can i use the same way old style but i want to use bootstrap)
2. After copying the document from the default collection to another collection, how can I retain the _sync properties (mainly rev and channels)? (do i need to make any changes in the sync json)
3. I encounter the error “Changes cannot be saved. SyncGateway is enabled on: {{bucket}}, deployment of source bucket mutating handler will cause Intra Bucket Recursion.” I am trying to delete the document from the default collection after moving it to a different collection.
4.

My main problem is i am cloning the document from default collection another collection using coucubase eventing but i am missing the _sync properties

Although i have update the database config like below

{
“name”: “gh-ucil-test”,
“bucket”: “gh-ucil-test”,
“scopes”: {
“_default”: {
“collections”: {
“dbc_task_progress”: {
“sync”: “function(doc, oldDoc, meta) { channel("legacy") }”,
“import_filter”: “function(doc) { return doc.type == "mobile" }”
},
“dbc_company_configuration”: {
“sync”: “function(doc, oldDoc, meta) { channel("collection1") }”,
“import_filter”: “function(doc) { return doc.type == "mobile" }”
}
}
}
},
“num_index_replicas”: 0
}’

I was able to solve this.

How do I convert a Sync Gateway JSON configuration from version 2.8 to 3.1.6? Is it converted automatically in the latest version? We want to use collections (the count is around 30). How do I configure the sync function for collections? Any inputs?

The above answer is also clear.
We are using an Eventing function to move data from one collection to another. After moving the data, I want to delete it from the default collection. I am also using Sync Gateway.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.