add-database-table
Create database migrations, define table schemas, and manage constant tables (enums). Use when: (1) creating a new database table, (2) running 'make migrate.create', (3) adding enum/status values, (4) modifying table structure. REQUIRED first step before add-domain-entity.
Best use case
add-database-table is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Create database migrations, define table schemas, and manage constant tables (enums). Use when: (1) creating a new database table, (2) running 'make migrate.create', (3) adding enum/status values, (4) modifying table structure. REQUIRED first step before add-domain-entity.
Teams using add-database-table should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/add-database-table/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How add-database-table Compares
| Feature / Agent | add-database-table | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Create database migrations, define table schemas, and manage constant tables (enums). Use when: (1) creating a new database table, (2) running 'make migrate.create', (3) adding enum/status values, (4) modifying table structure. REQUIRED first step before add-domain-entity.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Add Database Table
Create database migrations and constant tables for new entities.
## Quick Start
```bash
# 1. Create migration file
make migrate.create
# 2. Edit the generated SQL file in db/{database}/migrations/
# 3. Run migration and generate SQLBoiler models
make migrate.up
```
## Overview
```
add-database-table ──> add-domain-entity ──> add-api-endpoint
^
YOU ARE HERE
```
This skill is **Step 1** of the CRUD implementation workflow.
## Workflow
### Step 1: Create Migration File
Run the migration creation command:
```bash
make migrate.create
```
Enter a descriptive name when prompted (e.g., `create_examples_table`).
A new file is created at: `db/postgresql/migrations/{timestamp}_{name}.sql`
### Step 2: Define Constant Tables (if needed)
If the entity has status/enum fields, create the constant table **first**.
**Migration SQL:**
```sql
-- +goose Up
CREATE TABLE "example_statuses" (
"id" VARCHAR(64) PRIMARY KEY
);
-- +goose Down
DROP TABLE IF EXISTS "example_statuses";
```
**YAML Definition** in `db/postgresql/constants/constants.yaml`:
```yaml
- table: example_statuses
values:
- draft
- published
- archived
```
### Step 3: Write Main Table Migration
Use the template below, adapting field names and types:
```sql
-- +goose Up
CREATE TABLE "examples" (
"id" VARCHAR(64) PRIMARY KEY,
"tenant_id" VARCHAR(64) NOT NULL,
"name" VARCHAR(256) NOT NULL,
"description" TEXT NOT NULL,
"status" VARCHAR(64) NOT NULL,
"created_at" TIMESTAMPTZ NOT NULL,
"updated_at" TIMESTAMPTZ NOT NULL,
CONSTRAINT "examples_fkey_tenant_id"
FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id"),
CONSTRAINT "examples_fkey_status"
FOREIGN KEY ("status") REFERENCES "example_statuses" ("id")
);
CREATE INDEX "examples_idx_tenant_id" ON "examples" ("tenant_id");
CREATE INDEX "examples_idx_status" ON "examples" ("status");
CREATE INDEX "examples_idx_created_at" ON "examples" ("created_at" DESC);
-- +goose Down
DROP TABLE IF EXISTS "examples";
```
See [references/sql-patterns.md](references/sql-patterns.md) for advanced patterns.
### Step 4: Run Migration
```bash
make migrate.up
```
This command:
- Executes pending migrations
- Syncs constant table values from YAML
- Generates SQLBoiler models in `internal/infrastructure/{database}/internal/dbmodel/`
### Step 5: Verify
Confirm the SQLBoiler model was generated:
```
internal/infrastructure/postgresql/internal/dbmodel/examples.go
```
## Quick Reference
### Column Types
| Go Type | PostgreSQL | Notes |
|---------|------------|-------|
| `string` (ID) | `VARCHAR(64)` | Primary/foreign keys |
| `string` (short) | `VARCHAR(256)` | Names, titles |
| `string` (long) | `TEXT` | Descriptions |
| `int` | `INTEGER` | Counts, order |
| `bool` | `BOOLEAN` | Flags |
| `time.Time` | `TIMESTAMPTZ` | Always with timezone |
| `null.Time` | `TIMESTAMPTZ` | Nullable timestamps |
| `map/struct` | `JSONB` | Flexible data |
See [references/type-mappings.md](references/type-mappings.md) for complete mappings.
### Naming Conventions
| Type | Pattern | Example |
|------|---------|---------|
| Foreign Key | `{table}_fkey_{column}` | `examples_fkey_tenant_id` |
| Index | `{table}_idx_{column}` | `examples_idx_tenant_id` |
| Unique | `{table}_uq_{columns}` | `examples_uq_tenant_id_name` |
| Unique Index | `{table}_uidx_{column}` | `examples_uidx_email` |
## Checklist
- [ ] Migration file created with Up and Down sections
- [ ] Constant table created (if entity has status/enum)
- [ ] YAML constants defined in `db/postgresql/constants/constants.yaml`
- [ ] Foreign key constraints added
- [ ] Indexes created for foreign keys and common queries
- [ ] `make migrate.up` executed successfully
- [ ] SQLBoiler model generated in `dbmodel/`
## Next Step
Proceed to **add-domain-entity** skill to create:
- Domain model (`internal/domain/model/`)
- Repository interface (`internal/domain/repository/`)
- Repository implementation
- MarshallerRelated Skills
acsets-algebraic-databases
ACSets (Attributed C-Sets): Algebraic databases as in-memory data structures. Category-theoretic formalism for relational databases generalizing graphs and data frames.
Build Your Database Skill
Create a relational-db-agent skill that knows SQLModel async patterns
Backend Database Expert
专注于数据库设计、SQL 优化和迁移策略。
modal-deployment
Run Python code in the cloud with serverless containers, GPUs, and autoscaling using Modal. This skill enables agents to generate code for deploying ML models, running batch jobs, serving APIs, and scaling compute-intensive workloads.
vly-money
Generate crypto payment links for supported tokens and networks, manage access to X402 payment-protected content, and provide direct access to the vly.money wallet interface.
astro
This skill provides essential Astro framework patterns, focusing on server-side rendering (SSR), static site generation (SSG), middleware, and TypeScript best practices. It helps AI agents implement secure authentication, manage API routes, and debug rendering behaviors within Astro projects.
chrome-debug
This skill empowers AI agents to debug web applications and inspect browser behavior using the Chrome DevTools Protocol (CDP), offering both collaborative (headful) and automated (headless) modes.
lets-go-rss
A lightweight, full-platform RSS subscription manager that aggregates content from YouTube, Vimeo, Behance, Twitter/X, and Chinese platforms like Bilibili, Weibo, and Douyin, featuring deduplication and AI smart classification.
whisper-transcribe
Transcribes audio and video files to text using OpenAI's Whisper CLI, enhanced with contextual grounding from local markdown files for improved accuracy.
ontopo
An AI agent skill to search for Israeli restaurants, check table availability, view menus, and retrieve booking links via the Ontopo platform, acting as an unofficial interface to its data.
thor-skills
An entry point and router for AI agents to manage various THOR-related cybersecurity tasks, including running scans, analyzing logs, troubleshooting, and maintenance.
ux
This AI agent skill provides comprehensive guidance for creating professional and insightful User Experience (UX) designs, covering user research, information architecture, interaction design, visual guidance, and usability evaluation. It aims to produce actionable, user-centered solutions that avoid generic AI aesthetics.