ExDataSketch.Storage.Ecto.Migration (ExDataSketch v0.9.0)

Copy Markdown View Source

Migration helper for creating the ex_data_sketch_sketches table.

Use mix ex_data_sketch.gen.migration to generate a migration file that calls up_commands/0 and down_commands/0 from this module.

Table Structure

The migration creates a table named ex_data_sketch_sketches with:

  • id -- auto-incrementing primary key
  • key -- unique string key for the sketch (with unique index)
  • sketch_type -- the sketch family name (e.g., "hll", "cms")
  • data -- binary column storing the EXSK v2 frame
  • inserted_at -- timestamp
  • updated_at -- timestamp

Usage in Migrations

defmodule MyApp.Repo.Migrations.AddExDataSketchSketches do
  use Ecto.Migration

  def up do
    Enum.each(ExDataSketch.Storage.Ecto.Migration.up_commands(), &execute/1)
  end

  def down do
    Enum.each(ExDataSketch.Storage.Ecto.Migration.down_commands(), &execute/1)
  end
end

Summary

Functions

Returns the list of SQL commands to drop the sketches table.

Returns the table name used by the migration.

Returns the list of SQL commands to create the sketches table and index.

Functions

down_commands()

@spec down_commands() :: [String.t()]

Returns the list of SQL commands to drop the sketches table.

Each command is a SQL string suitable for passing to Ecto.Migration.execute/1.

table_name()

@spec table_name() :: String.t()

Returns the table name used by the migration.

Examples

iex> ExDataSketch.Storage.Ecto.Migration.table_name()
"ex_data_sketch_sketches"

up_commands()

@spec up_commands() :: [String.t()]

Returns the list of SQL commands to create the sketches table and index.

Each command is a SQL string suitable for passing to Ecto.Migration.execute/1.