← 返回 Skills 市场
matrixtrickery

DB Schema Generator

作者 MatrixTrickery · GitHub ↗ · v1.0.0 · MIT-0
darwinlinuxwin32 ✓ 安全检测通过
643
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install db-schema-gen
功能描述
Generate database schemas, migrations, and ERD diagrams from plain English descriptions — supports PostgreSQL, MySQL, SQLite, and MongoDB with proper indexes...
使用说明 (SKILL.md)

\r \r

DB Schema\r

\r Describe your data model in English. Get production-ready schema, migrations, and diagrams.\r \r

What It Does\r

\r Takes a plain English description of your data and generates:\r

  • SQL schema (CREATE TABLE statements with constraints)\r
  • Migration files (for Prisma, Drizzle, Knex, Alembic, etc.)\r
  • Entity-Relationship diagram (Mermaid or ASCII)\r
  • Indexes (auto-detected from common query patterns)\r
  • Seed data (realistic sample data for development)\r \r

Usage\r

\r

From description:\r

db-schema "Users have many posts. Posts have many comments. Users can like posts."\r
```\r
\r
### With options:\r
```\r
db-schema "E-commerce with products, orders, customers" --dialect postgres --orm prisma\r
```\r
\r
### Options:\r
- `--dialect` — `postgres` (default), `mysql`, `sqlite`, `mongodb`\r
- `--orm` — `raw` (default), `prisma`, `drizzle`, `knex`, `sqlalchemy`, `typeorm`\r
- `--format` — `sql` (default), `json`, `markdown`\r
- `--diagram` — include ERD diagram: `mermaid` (default), `ascii`, `none`\r
- `--seed` — generate seed data (default: false)\r
- `--seed-count` — rows per table for seed data (default: 10)\r
\r
## Generation Rules\r
\r
### Schema Design:\r
1. **Every table gets a primary key** — `id` (BIGSERIAL for PG, AUTO_INCREMENT for MySQL, INTEGER AUTOINCREMENT for SQLite)\r
2. **Timestamps by default** — `created_at` and `updated_at` on every table\r
3. **Foreign keys with proper naming** — `table_id` references `table(id)`\r
4. **ON DELETE behavior** — CASCADE for owned relationships, SET NULL for optional\r
5. **Proper types** — use appropriate types (TEXT not VARCHAR(255) for PG, TIMESTAMPTZ not TIMESTAMP)\r
\r
### Relationship Detection:\r
\r
| English | Relationship | Implementation |\r
|---------|-------------|---------------|\r
| "has many" | One-to-Many | FK on the "many" side |\r
| "belongs to" | Many-to-One | FK on current table |\r
| "has one" | One-to-One | FK with UNIQUE constraint |\r
| "many to many" | Many-to-Many | Junction table |\r
| "can like/follow/tag" | Many-to-Many | Junction table with metadata |\r
\r
### Auto-Indexing:\r
\r
| Pattern | Index Type |\r
|---------|-----------|\r
| Foreign keys | B-tree index |\r
| Email, username | UNIQUE index |\r
| Created/updated dates | B-tree index |\r
| Status/type/role columns | B-tree index |\r
| Full-text search fields | GIN index (PG) / FULLTEXT (MySQL) |\r
| Slug/path columns | UNIQUE index |\r
| Composite lookups | Composite index |\r
\r
### Type Mapping:\r
\r
| Concept | PostgreSQL | MySQL | SQLite |\r
|---------|-----------|-------|--------|\r
| ID | BIGSERIAL | BIGINT AUTO_INCREMENT | INTEGER |\r
| Short text | VARCHAR(N) | VARCHAR(N) | TEXT |\r
| Long text | TEXT | TEXT | TEXT |\r
| Money | NUMERIC(12,2) | DECIMAL(12,2) | REAL |\r
| Boolean | BOOLEAN | TINYINT(1) | INTEGER |\r
| Timestamp | TIMESTAMPTZ | DATETIME | TEXT |\r
| JSON | JSONB | JSON | TEXT |\r
| UUID | UUID | CHAR(36) | TEXT |\r
| Enum | Custom TYPE | ENUM(...) | TEXT CHECK |\r
\r
### Output (SQL):\r
```sql\r
-- Generated by db-schema\r
-- Description: E-commerce with products, orders, customers\r
\r
CREATE TABLE customers (\r
    id BIGSERIAL PRIMARY KEY,\r
    email VARCHAR(255) NOT NULL UNIQUE,\r
    name VARCHAR(255) NOT NULL,\r
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),\r
    updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()\r
);\r
\r
CREATE TABLE products (\r
    id BIGSERIAL PRIMARY KEY,\r
    name VARCHAR(255) NOT NULL,\r
    description TEXT,\r
    price NUMERIC(12,2) NOT NULL CHECK (price >= 0),\r
    stock INTEGER NOT NULL DEFAULT 0,\r
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),\r
    updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()\r
);\r
\r
CREATE TABLE orders (\r
    id BIGSERIAL PRIMARY KEY,\r
    customer_id BIGINT NOT NULL REFERENCES customers(id) ON DELETE CASCADE,\r
    status VARCHAR(50) NOT NULL DEFAULT 'pending',\r
    total NUMERIC(12,2) NOT NULL DEFAULT 0,\r
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),\r
    updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()\r
);\r
\r
CREATE TABLE order_items (\r
    id BIGSERIAL PRIMARY KEY,\r
    order_id BIGINT NOT NULL REFERENCES orders(id) ON DELETE CASCADE,\r
    product_id BIGINT NOT NULL REFERENCES products(id) ON DELETE RESTRICT,\r
    quantity INTEGER NOT NULL CHECK (quantity > 0),\r
    unit_price NUMERIC(12,2) NOT NULL\r
);\r
\r
CREATE INDEX idx_orders_customer_id ON orders(customer_id);\r
CREATE INDEX idx_orders_status ON orders(status);\r
CREATE INDEX idx_order_items_order_id ON order_items(order_id);\r
CREATE INDEX idx_order_items_product_id ON order_items(product_id);\r
```\r
\r
### ERD Output (Mermaid):\r
```\r
erDiagram\r
    CUSTOMERS ||--o{ ORDERS : places\r
    ORDERS ||--|{ ORDER_ITEMS : contains\r
    PRODUCTS ||--o{ ORDER_ITEMS : "included in"\r
```\r
安全使用建议
This skill is an instruction-only text generator (it produces SQL, migration templates, ERD text). It does not install code or ask for credentials, so installing it carries low technical risk. However: (1) do not paste sensitive or production secrets/PII into prompts — seed data generation can mirror input content; (2) treat generated SQL/migrations as draft: review and test before applying to production databases; (3) the SKILL.md shows CLI examples but no binary is supplied — the agent will generate text, it will not run local migration commands for you. If you need an executable tool integrated into your environment, you should verify or supply a vetted implementation separately.
功能分析
Type: OpenClaw Skill Name: db-schema-gen Version: 1.0.0 The skill bundle is a documentation-only package providing instructions for an AI agent to generate database schemas and ERD diagrams from natural language. It contains no executable code, scripts, or network-enabled components, and the instructions in SKILL.md are strictly limited to the stated purpose of schema generation without any signs of prompt injection or malicious intent.
能力评估
Purpose & Capability
Name and description (generate schemas, migrations, ERDs) match the SKILL.md content. The skill requests no binaries, env vars, or config paths — which is proportional for an instruction-only generator.
Instruction Scope
SKILL.md stays focused on generating schemas, migrations, ERDs, indexes, and seed data from English descriptions. It does include CLI-style usage examples (e.g., `db-schema "..."`) despite there being no install/binary provided — this is a documentation/example artifact rather than an instruction to access system binaries. Also note the seed-data feature could encourage users to paste realistic data into prompts; avoid including private/PII in inputs.
Install Mechanism
No install spec and no code files are present, so nothing is downloaded or written to disk. This is the lowest-risk model for a skill of this type.
Credentials
The skill declares no required environment variables, credentials, or config paths. The instructions do not reference any hidden env vars or credentials — access requests are proportionate to the stated purpose.
Persistence & Privilege
always:false and default invocation settings are appropriate. The skill does not request persistent system presence or modify other skills/configs.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install db-schema-gen
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /db-schema-gen 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release of db-schema skill. - Generate SQL schemas, migration files, and ER diagrams from English descriptions. - Supports PostgreSQL, MySQL, SQLite, and MongoDB (index/constraint aware). - Auto-detects relationships (one-to-many, many-to-many, etc.) and adds proper foreign keys. - Offers ORM and dialect options (Prisma, Drizzle, Knex, SQLAlchemy, TypeORM). - Produces diagrams (Mermaid/ASCII), realistic seed data, and follows best schema practices.
元数据
Slug db-schema-gen
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

DB Schema Generator 是什么?

Generate database schemas, migrations, and ERD diagrams from plain English descriptions — supports PostgreSQL, MySQL, SQLite, and MongoDB with proper indexes... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 643 次。

如何安装 DB Schema Generator?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install db-schema-gen」即可一键安装,无需额外配置。

DB Schema Generator 是免费的吗?

是的,DB Schema Generator 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

DB Schema Generator 支持哪些平台?

DB Schema Generator 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(darwin, linux, win32)。

谁开发了 DB Schema Generator?

由 MatrixTrickery(@matrixtrickery)开发并维护,当前版本 v1.0.0。

💬 留言讨论