搜索

PythonReactSEOPDF
OpenClaw

ecto-migrator

Generate Ecto migrations from natural language or schema descriptions. Handles tables, columns, indexes, constraints, references, enums, and partitioning. Supports reversible migrations, data migrations, and multi-tenant patterns. Use when creating or modifying database schemas, adding indexes, altering tables, creating enums, or performing data migrations in an Elixir project.

gchapim0 来源安装数☆ 0 仓库 Stars

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

SkillHub CLI

skillhub install gchapim/ecto-migrator

打开来源仓库,查看说明和兼容环境后,按来源提供的命令或步骤安装。

将来源链接提供给你的 Agent,让它先读取说明、核对依赖,并向你说明将执行的安装步骤。

查看来源 ↗使用指南

技能说明

Ecto Migrator

Generating Migrations

From Natural Language

Parse the user's description and generate a migration file. Common patterns:

User Says Migration Action
"Create users table with email and name" create table(:users) with columns
"Add phone to users" alter table(:users), add :phone
"Make email unique on users" create unique_index(:users, [:email])
"Add tenant_id to all tables" Multiple alter table with index
"Rename status to state on orders" rename table(:orders), :status, to: :state
"Remove the legacy_id column from users" alter table(:users), remove :legacy_id
"Add a check constraint on orders amount > 0" create constraint(:orders, ...)
File Naming
mix ecto.gen.migration <name>
# Generates: priv/repo/migrations/YYYYMMDDHHMMSS_<name>.exs

Name conventions: create_<table>, add_<column>_to_<table>, create_<table>_<column>_index, alter_<table>_add_<columns>.

Migration Template

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

  def change do
    create table(:users, primary_key: false) do
      add :id, :binary_id, primary_key: true
      add :email, :string, null: false
      add :name, :string, null: false
      add :role, :string, null: false, default: "member"
      add :metadata, :map, default: %{}
      add :tenant_id, :binary_id, null: false

      add :team_id, references(:teams, type: :binary_id, on_delete: :delete_all)

      timestamps(type: :utc_datetime_usec)
    end

    create unique_index(:users, [:tenant_id, :email])
    create index(:users, [:tenant_id])
    create index(:users, [:team_id])
  end
end

Column Types

See references/column-types.md for complete type mapping and guidance.

Key decisions:

  • IDs: Use :binary_id (UUID) — set primary_key: false on table, add :id manually.
  • Money: Use :integer (cents) or :decimal —...

来源信息

Source
github
Repository
openclaw/skills
Path
skills/gchapim/ecto-migrator
Version
—
Commit
c71c3484b294a6e9cd0ac9a38352c78cbc6c25d9
分类来源
rules
状态
active
可见性
public

这些信息来自收录时的来源分析,可能滞后;使用前请核对最新来源文件。

来源内容

SKILL.md
# Ecto Migrator

## Generating Migrations

### From Natural Language

Parse the user's description and generate a migration file. Common patterns:

| User Says | Migration Action |
|-----------|-----------------|
| "Create users table with email and name" | `create table(:users)` with columns |
| "Add phone to users" | `alter table(:users), add :phone` |
| "Make email unique on users" | `create unique_index(:users, [:email])` |
| "Add tenant_id to all tables" | Multiple `alter table` with index |
| "Rename status to state on orders" | `rename table(:orders), :status, to: :state` |
| "Remove the legacy_id column from users" | `alter table(:users), remove :legacy_id` |
| "Add a check constraint on orders amount > 0" | `create constraint(:orders, ...)` |

### File Naming

```bash
mix ecto.gen.migration <name>
# Generates: priv/repo/migrations/YYYYMMDDHHMMSS_<name>.exs
```

Name conventions: `create_<table>`, `add_<column>_to_<table>`, `create_<table>_<column>_index`, `alter_<table>_add_<columns>`.

## Migration Template

```elixir
defmodule MyApp.Repo.Migrations.CreateUsers do
  use Ecto.Migration

  def change do
    create table(:users, primary_key: false) do
      add :id, :binary_id, primary_key: true
      add :email, :string, null: false
      add :name, :string, null: false
      add :role, :string, null: false, default: "member"
      add :metadata, :map, default: %{}
      add :tenant_id, :binary_id, null: false

      add :team_id, references(:teams, type: :binary_id, on_delete: :delete_all)

      timestamps(type: :utc_datetime_usec)
    end

    create unique_index(:users, [:tenant_id, :email])
    create index(:users, [:tenant_id])
    create index(:users, [:team_id])
  end
end
```

## Column Types

See [references/column-types.md](references/column-types.md) for complete type mapping and guidance.

Key decisions:
- **IDs**: Use `:binary_id` (UUID) — set `primary_key: false` on table, add `:id` manually.
- **Money**: Use `:integer` (cents) or `:decimal` —...

相关技能

OpenClaw

1password

daggerkun007

Set up and use 1Password CLI (op). Use when installing the CLI, enabling desktop app integration, signing in (single or multi-account), or reading/injecting/running secrets via op.