Thin wrapper for executing CQL schema migrations via Xandra directly.
Replaces the Exandra/Ecto.Migration pattern. Since CQL has no transactional DDL, each statement is executed independently.
Usage
Start a temporary connection for migrations:
AshScylla.Migrator.run("127.0.0.1:9042", [
"CREATE KEYSPACE IF NOT EXISTS my_app " <>
"WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': 1}",
"CREATE TABLE IF NOT EXISTS my_app.users (id UUID PRIMARY KEY, name TEXT)"
])In a Mix task or release task:
AshScylla.Migrator.run!(nodes, statements,
keyspace: "my_app",
connect_timeout: 10_000
)Functions
Summary
Functions
@spec run(String.t() | [String.t()], [String.t()], keyword()) :: {:ok, [term()]} | {:error, {non_neg_integer(), term()}}
Executes a list of CQL statements against a ScyllaDB node.
A temporary connection is started, all statements are executed sequentially, and the connection is stopped.
Returns {:ok, results} or {:error, {failed_index, reason}}.
Same as run/3 but raises on error.
@spec run_on(atom(), [String.t()]) :: {:ok, [term()]} | {:error, {non_neg_integer(), term()}}
Executes CQL statements against an existing named connection.