AgentSkillsCN

database-design

创建数据库设计文档,作为表、列与关系的权威参考。利用这些文档生成迁移、模型与工厂。在创建架构、表、模型、迁移或工厂时自动激活。

SKILL.md
--- frontmatter
name: database-design
description: >-
  Creates database design documents that serve as source of truth for tables,
  columns, and relationships. Uses these documents to generate migrations, models,
  and factories. Activates when creating schemas, tables, models, migrations, or
  factories.

Database Design

Activate this skill when:

  • Creating design documents, migrations, models, or factories.

Standard Column Reference

Reference of standard column names, types, and naming conventions used across the project. Use these patterns when creating new tables to maintain consistency.

Keep logical order when creating new tables.

Column NameTypeNullableDefaultPurpose
idbigint unsignedNoAUTOPrimary key
codevarchar(255)NoUNIQUEHuman-readable identifier
namevarchar(255)No-Simple label/display name
titlevarchar(255)No-Formal display name
slugvarchar(255)No-URL-safe identifier
headlinevarchar(255)Yes-Featured headline/tagline
intromediumTextYes-Short introductory text
contentlongTextYes-Main body content
image_namevarchar(255)Yes-Stored image filename
file_namevarchar(255)Yes-Stored file name
pricebigint unsignedYes0Product price in cents
stockbigint unsignedNo0Quantity available
quantitybigint unsignedNo1Quantity for order details
unit_pricebigintNo0Order item price (signed)
extra_datajsonYes-Flexible additional data
published_attimestampYes-When content went live
released_attimestampYes-When content became available

Notes

  • created_at and updated_at are standard columns and assumed on all tables unless stated.
  • deleted_at is optional and used only where soft deletes are required.
  • Use the Purpose column in the Reference Table only for internal context; for the Schema Document, the Notes column should only contain technical constraints (PK, FK, UNIQUE, etc.).

Design Document Template

Use this template for all new table definitions.

markdown
## Table: [TableName]

### Purpose

A short description of what this table stores or represents.

### Columns

| Column   | Type            | Nullable | Default   | Notes               |
| -------- | --------------- | -------- | --------- | ------------------- |
| id       | bigint unsigned | No       | AUTO      | PK                  |
| [column] | [type]          | [Yes/No] | [default] | [PK/FK/UNIQUE only] |
| ...      | ...             | ...      | ...       | ...                 |

### Constraints

List anything not obvious from the column definitions, like:

* Foreign keys (`column` references `other_table.id`)
* Soft deletes
* Composite keys or checks

### Relationships

Human-readable description of relationships with other tables:

* [Table] has many [Table]
* [Table] can belong to [Table]
* ...