Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

Tri avatar image
Tri asked ·

Can you suggest a solution for managing a single DDL script that can be used for multiple environments?

Let's say I have multiple deployment environments which have Cassandra cluster of various size:

  • local test: 1 node
  • dev: 3 nodes
  • production: 5 nodes

The same DDL script is used to initialize the schema on these environments. Except for the keyspace `replication_factor` parameter: Example:

// Dev cluster 3 nodes
CREATE KEYSPACE tinydemo WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 3 }; 

Can you please suggest an elegant solution to manage a single DDL script while still being able to deploy on various environments with a parameterizable `replication_factor`?

schema
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered ·

There isn't an off-the-shelf solution for this but it should be simple enough to implement in a shell script.

Hopefully, other community members here will respond with their home-grown scripts. Cheers!

2 comments Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Hi,

Thanks for the input. I thought there could be an elegant CQL. Otherwise string replacement on the *.cql is straightforward which is what we are currently doing.

0 Likes 0 ·
Not with CQL, no. You'll have to construct the string before sending the DDL to the cluster. Cheers!
0 Likes 0 ·