mix attesto_mcp_server.gen.migration (attesto_mcp_server v0.14.0)

Copy Markdown View Source

Generates the Ecto migration backing AttestoMCP.Server.SessionStore.Ecto.

The generated migration creates one PostgreSQL table, attesto_mcp_sessions. Rows are keyed by the pair {namespace, session_id} so several independently named MCP servers can safely share a repository. The complete versioned session record is stored as JSONB in record; created_at_ms, last_seen_ms, absolute_timeout_ms, and idle_timeout_ms mirror the record for validation, while expires_at_ms is a denormalized value used for bounded SQL-side expiry filtering and cleanup. The record remains the source of truth; these query values are refreshed whenever the record is saved or touched.

This task only writes a migration file. It never invokes Ecto.Migrator or changes the database. Apply the file from the host application's normal migration workflow.

Usage

mix attesto_mcp_server.gen.migration --repo MyApp.Repo

Options

  • --repo - the Ecto repo the migration is generated for. It may be supplied more than once when several repos intentionally share the same application package. When omitted, configured Ecto repos are discovered using Mix.Ecto, and none or an ambiguous set is rejected.
  • --schema-prefix - an optional validated PostgreSQL schema used as Ecto's prefix: for every table and index. The schema is created with CREATE SCHEMA IF NOT EXISTS by the migration and is left in place on rollback. The table name is fixed because the runtime schema queries attesto_mcp_sessions.
  • --migrations-path - directory in which the migration is written. It defaults to the repo's priv/<repo>/migrations directory. An explicit path may only be used with one repo so generation cannot partially write two competing migrations into the same directory.

A second invocation refuses to create a duplicate migration for the same path. This makes the table layout discoverable and prevents two generated migrations from competing over the same runtime schema.