Hello, everyone!
I am currenlty working on a custom Webcrawler pet-service, written in Elixir and using Cassandra as a database.
I am using Xandra as a driver.
Can anyone suggest migration tools for this kind of database ?
I discovered some ecto-based packages on top of cqerl and Xandra, but with longly outdated dependencies.
So, does some kind of migrator exists for cassandra?
Thanks! 
We ran into the same issue as you (no packages looked good), so we basically just copied Ecto migrations ourselves, i.e. we have a schema_migrations
table in each keyspace. Itâs a bit more complicated cuz weâre multitenanted, and thus have a keyspace for each tenant.
In retrospect, and after several side projects, Iâm not sure that was the easiest approach. You can simply just use Ecto migrations to manage your Cassandra schema. Ecto migrations are just a generic way to make sure some chunk of code gets run only one time; nothing stopping you from writing migrations that alter Cassandra schema.
Edit: I assumed youâre also using a relational database and thus Ecto.
1 Like
Thanks for the reply.
The idea of using some kind of Cassandra Ecto driver and Ecto just for migrations may be the way to go.
No no, I mean just use straight up Ecto migrations, no need for a âCassandra Ectoâ driver at allâŠ
defmodule Repo.Migrations.CreateFooKeyspace do
use Ecto.Migration
def up do
{:ok, conn} = Xandra.start_link(...)
Xandra.execute!(conn, """
CREATE KEYSPACE foo ...
""")
end
def down do
{:ok, conn} = Xandra.start_link(...)
Xandra.execute!(conn, """
DROP KEYSPACE foo ...
""")
end
end
There is nothing stopping you from running arbitrary code in Ecto migrations.
I see.
Blockquote
Edit: I assumed youâre also using a relational database and thus Ecto.
Do you use another DB for the schema_migrations
table ? Like postgres or ETS ?
Yes, we use Postgres for relation data.
But if youâre not using some relational database already, adding one to your infra just to use Ecto migrations to manage Cassandra schema doesnât seem like a good idea.