AshScylla.Migrator (AshScylla v1.2.0)

Copy Markdown View Source

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

  • run/3 — Start temp connection, execute statements, stop connection
  • run!/3 — Same as run/3 but raises on error
  • run_on/2 — Execute against an existing named connection
  • run_on!/2 — Same as run_on/2 but raises on error

Summary

Functions

Executes a list of CQL statements against a ScyllaDB node.

Same as run/3 but raises on error.

Executes CQL statements against an existing named connection.

Functions

run(nodes, statements, opts \\ [])

@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}}.

run!(nodes, statements, opts \\ [])

@spec run!(String.t() | [String.t()], [String.t()], keyword()) ::
  [term()] | no_return()

Same as run/3 but raises on error.

run_on(conn_name, statements)

@spec run_on(atom(), [String.t()]) ::
  {:ok, [term()]} | {:error, {non_neg_integer(), term()}}

Executes CQL statements against an existing named connection.

run_on!(conn_name, statements)

@spec run_on!(atom(), [String.t()]) :: [term()] | no_return()