I have this table in cassandra
CREATE TABLE daily_stats (
day text,
user text,
clicks counter
PRIMARY KEY ((day, user))
)
All I need to change is the partitioning key to
PRIMARY KEY (day, user)
Now cassandra does not allow me to alter table like this. It also does not support table renaming.
So the only way to update primary key in cassandra table is to create new table and migrate data to it from old table. That's easy.
But I would like to prepare the infrastructure for other such future changes.
What I can easily come up with is add version suffixes for every table
daily_stats_v1
daily_stats_v2
Or to every keyspace
app_stats_v1
app_stats_v2
Then it would be really easy to create the new fixed table, update apps to use this table and finally migrate data from old table.
Anyways, I'm more interested in good practices and "the proper ways to do it".