How to deal with schema changes in Couchbase

Hello Team,

I come from an RDBMS background and have recently started exploring Couchbase. In traditional relational databases, we often write migration scripts to manage schema changes like adding a column or creating a new table. I understand that in Couchbase, we can simply add a new key to a collection without the need for migration scripts. However, I have a question regarding creating a new collection.

Since we are working in a team, if I create a new collection and my pull request is merged, I want this change to be reflected in other developers’ systems when they run a certain command. We are using Ruby on Rails for our application.

Could you please provide guidance on how to handle creating new collections in Couchbase in a team setting and ensure that these changes are applied uniformly across all team members’ systems?

Thank you!

Since you come from an RDBMS background - it would be handled the same was as adding a new table to an RDBMS.

I understand that in Couchbase, we can simply add a new key to a collection without the need for migration scripts

That is not accurate. At the very least, every cluster that wishes to use the new key(index) would need a script that adds the index to the cluster. And if a collection is added, they need a script that adds the collection.

The “schema changes” that don’t need anything are things like adding a new type of document to a bucket or collection. Or removing properties from a document - n1ql that projects deleted properties will not fail. n1ql that has predicates on deleted properties will not fail - although depending on the predicate it may evaluate to false. Or adding properties to a document. However, if you wish to “migrate” the data, perhaps by removing a property from existing documents that have it, or adding a property with a certain value to a set of documents - that would require a script.

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