mix ash_scylla.gen (AshScylla v0.10.0)

Copy Markdown View Source

Generates a schema migration file from Ash DSL resource definitions.

Scans the project for Ash resources using AshScylla.DataLayer and produces a priv/migrations/<timestamp>_<name>.ex file containing CREATE TABLE and CREATE INDEX CQL statements derived from each resource's attributes and secondary indexes.

Usage

# Auto-generate schema file with timestamp-based name
mix ash_scylla.gen --dev

# Generate with a specific schema module name
mix ash_scylla.gen AddUserTable

# Generate for a specific resource only
mix ash_scylla.gen --resource MyApp.User

Options

  • --dev — auto-name the schema file (timestamp-based). If no name argument is given, --dev is assumed.
  • --resource — only generate schema for the given resource module.

Output

Generated files go to priv/migrations/ and use AshScylla.Schema:

defmodule MyApp.Migrations.AddUserTable do
  @moduledoc """
  Schema migration generated by `mix ash_scylla.gen`.
  """

  use AshScylla.Schema

  @impl AshScylla.Schema
  def change do
    [
      "CREATE TABLE IF NOT EXISTS users (id UUID PRIMARY KEY, name TEXT, email TEXT)",
      "CREATE INDEX IF NOT EXISTS idx_users_email ON users (email)"
    ]
  end
end

Run migrations with: mix ash_scylla.migrate