I want to migrate serviceconfig.json from sync gateway 2.8 to 3.1

Hello,
I want to migrate serviceconfig.json from sync gateway 2.8 to 3.1.
I don’t understand the new architecture (scopes or sync)
In particular, we used the databases part and the “sync” function to filter and define channels.

I transformed the databases part like this but it doesn’t work.

"databases": {
    "nestor-referential": {
      "name": "referentialname",
      "bucket": "referential",
      "allow_conflicts": true,
      "num_index_replicas": 0,
      "revs_limit": 250,
      "enable_shared_bucket_access": true,
      "import_docs": true,
	  "scopes": {
		  "referential" : {
			  "collections": {
				  "system-user": {
					"import_filter": "function(doc, oldDoc) { if (doc.type == 'SystemUser' || doc.type == 'SystemUserSettings' || (oldDoc != null && (oldDoc.type == 'SystemUser' || oldDoc.type == 'SystemUserSettings'))) { return false; } return true; }",
					"sync": "function(doc, oldDoc){channel('system-user');}"
				  },
				  "logs": {
					"import_filter": "function(doc, oldDoc) { if (doc.type == 'Log' || (oldDoc != null && oldDoc.type == 'Log') { return false; } return true; }",
					"sync": "function(doc, oldDoc){channel('logs');}"
				  },
				  "referentials": {
					"import_filter": "function(doc, oldDoc) { if(doc.type != 'Database' && doc.type != 'Synchronisation' && (oldDoc == null || (oldDoc.type != 'Database' && oldDoc.type != 'Synchronisation'))) { return false; } return true; }",
					"sync": "function(doc, oldDoc){channel('referential');}"
				  }
			  }
		  }
	  }
    }
  },

here’s the original in 2.8 version

 "databases": {
    "nestor-referential": {
      "server": "http://localhost",
      "bucket": "referential",
      "username": "SYNC-GATEWAY",
      "password": "SYNC-GATEWAY",
      "allow_conflicts": true,
      "num_index_replicas": 0,
      "revs_limit": 250,
      "enable_shared_bucket_access": true,
      "import_docs": true,
      "feed_type": "DCP",
      "users": {
        "GUEST": {
          "disabled": true,
          "admin_channels": [ "*" ]
        }
      },
	"sync": `function (doc, oldDoc) {
          if (doc.type == "SystemUser" || doc.type == "SystemUserSettings" || (oldDoc != null && (oldDoc.type == "SystemUser" || oldDoc.type == "SystemUserSettings")))
              channel("system-user");
          else if (doc.type == "Log" || (oldDoc != null && oldDoc.type == "Log"))
              channel("logs");
	      else if(doc.type != "Database" && doc.type != "Synchronisation" && (oldDoc == null || (oldDoc.type != "Database" && oldDoc.type != "Synchronisation")))
              channel("referential");
      }`
    }
}

Can you help me?

Do you want to just get your existing config running on version 3.1 and not use collections, or do you want to do a full migration to collections? Either option is valid.

If migrating, have you created the scopes and collections you’re defining on Couchbase Server? Have you migrated data to the new collections?

What do you see happening? There is no information about how this is not working.

in a first , i just want get my existing config running on version 3.1.
If i configure databases in the config file, Sync Gateway service don’t start up.
if i use REST API to create my databases, with one database (fiches), it work, but with an another (referential) don’t work.
I have the error "503 DB is currently under maintenance’.
if i want to make online my database, it says to resync.
After resync, the same error is already

        {
			"bucket": "fiches",
			"name": "fiches",
			"sync": `function (doc, oldDoc) {
						if (doc.isCanceled)
         						throw ({ forbidden: "Canceled document" });
						if (doc.commercialAffecte != null && doc.commercialAffecte.id != null)
							channel("fiches-" + doc.commercialAffecte.id);
					}`,
			"revs_limit": 250,
			"import_docs": true,
			"import_partitions": 16,
			"import_backup_old_rev": false,
			"allow_empty_password": true,
			"cache": {
				"rev_cache": {
					"size": 5000,
					"shard_count": 16
				},
				"channel_cache": {
					"max_number": 50000,
					"compact_high_watermark_pct": 80,
					"compact_low_watermark_pct": 60,
					"max_wait_pending": 5000,
					"max_num_pending": 10000,
					"max_wait_skipped": 3600000,
					"enable_star_channel": false,
					"max_length": 500,
					"min_length": 50,
					"expiry_seconds": 60
				}
			},
			"offline": false,
			"unsupported": {
				"warning_thresholds": {
					"xattr_size_bytes": 943718,
					"channels_per_doc": 50,
					"access_and_role_grants_per_doc": 50,
					"channels_per_user": 50000,
				   "channel_name_size": 250
				}
			},
			"feed_type": "DCP",
			"old_rev_expiry_seconds": 300,
			"view_query_timeout_secs": 75,
			"local_doc_expiry_secs": 7776000,
			"enable_shared_bucket_access": true,
			"session_cookie_secure": false,
			"session_cookie_http_only": true,
			"allow_conflicts": true,
			"num_index_replicas": 0,
			"use_views": false,
			"send_www_authenticate_header": true,
			"slow_query_warning_threshold": 500,
			"delta_sync": {
				"enabled": false,
				"rev_max_age_seconds": 86400
			},
			"compact_interval_days": 3,
			"sgreplicate_enabled": true,
			"sgreplicate_websocket_heartbeat_secs": 300,
			"serve_insecure_attachment_types": false,
			"query_pagination_limit": 5000,
			"client_partition_window_secs": 2592000,
			"guest": {
				"admin_channels": ["*"],
				"disabled": false
			}
		}
	
``

and the other don't work.
only changes are bucket, name and sync parameters

		"bucket": "referential",
		"name": "nestor-referential",
		"sync": `function (doc, oldDoc) {
					  if (doc.type == "SystemUser" || doc.type == "SystemUserSettings" || (oldDoc != null && (oldDoc.type == "SystemUser" || oldDoc.type == "SystemUserSettings")))
						  channel("system-user");
					  else if (doc.type == "Log" || (oldDoc != null && oldDoc.type == "Log"))
						  channel("logs");
					  else if(doc.type != "Database" && doc.type != "Synchronisation" && (oldDoc == null || (oldDoc.type != "Database" && oldDoc.type != "Synchronisation")))
						  channel("referential");
				  }`,

Does this use a custom group ID in the bootstrap configuration? If so, this may be hitting CBG-3528.

If not, what are the contents of the following documents: _sync:syncInfo and _sync:registry? What are the keys of documents that start with _sync:dbconfig that exist in your bucket?