nodecosmos / charybdis

Rust ORM for ScyllaDB and Apache Cassandra
MIT License
128 stars 8 forks source link

[Idea] Charybdis Migrate: Keyspaces #8

Closed DanielHe4rt closed 7 months ago

DanielHe4rt commented 7 months ago

I was wondering if there's any possibility to create Keyspaces directly from a file inside models/ folder. Something like: src/models/keyspaces.rs

Also set it as default for each model in the like:

#[charybdis_model(
keyspace_name = "leaderboard"
table_name = song_leaderboard,
partition_keys = [song_id, modifiers, difficulty, instrument],
clustering_keys = [player_id, score],
global_secondary_indexes = [],
local_secondary_indexes = [],
table_options = "
  CLUSTERING ORDER BY (player_id ASC, score DESC)
",
)]

Even if it's just ONE keyspace, it would be better to keep re-running these migrations from scratch...

Thanks in advance!

GoranBrkuljan commented 7 months ago

I am not sure about this. Correct me if I am wrong, but we would usually use single keyspace per app (service) and we usually define keyspace on session level with use_keyspace. If we allow multiple keyspaces we would have to integrate keyspace into query and we would have to require definition of it for each model which might introduce overhead. Let me know about common use cases for this, but for now I don't think we should implement this.