sky-uk / cqlmigrate

Cassandra schema migration library
BSD 3-Clause "New" or "Revised" License
47 stars 29 forks source link

ability to generate the bootstrap.cql from a template #46

Open chrishughes25 opened 7 years ago

chrishughes25 commented 7 years ago

I would like the ability to provide a bootstrap.template, with the keyspace name, and the replication factor as replaceable values, so that don't have to duplicate the bootstrap.cql for each environment.

oliverlockwood commented 7 years ago

@chrishughes25 I've also thought that something like this would be a good idea.

Would you please provide an example of the kind of bootstrap.template file you envisage (just as a comment would be fine for now), so we can discuss further?

chrishughes25 commented 7 years ago

@oliverlockwood bootstrap.template would contain the cql required to create a keyspace, (and tables). It would allow 2 replacement variables, {keyspace} and {replication} which the library would expose through its api. It would be mandatory to include the bootstrap.template file, either at the root classpath level, (or this could be a configurable item.) and would take the place of the bootstrap.cql The library would read the template and replace the values, then apply it as it does for a bootstrap.cql.

To maintain the replication factor in sync with the properties files, requires additional work. This can use the existing functionality used to apply the deltas, by writing the alter keyspace statement into a file in the /cql directory, with the name to include the checksum of the replicationFactor being applied. (This allows the existing schema-update functionality to make sure the statement is only applied once)

bluedigits commented 3 years ago

Wouldn't this proposal limit you to have one keyspace only?