본문으로 건너뛰기
cccskills
무료GitHub에 공개

database-table-creator

Creates database table with full Kotlin synchronization (SQL migration → Table → Entity → Repository → Tests). Use when adding new database tables or entities.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(5)

  • SKILL.md4.4 KB
  • examples.md15.8 KB
  • kotlin-templates.md11.3 KB
  • migration-template.sql2.7 KB
  • validation-checklist.md11.3 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Database Table Creator Skill

Creates complete database table implementation with SQL migration, Kotlin code, and comprehensive tests.

What This Skill Does

Generates:

  1. SQL Migration - PostgreSQL table with soft deletes, indexes, triggers
  2. Kotlin Table Object - Exposed ORM table definition (extends UUIDTable)
  3. Entity Data Class - Kotlin entity implementing Entity<Instant>
  4. Repository Interface + Implementation - CRUD operations with soft delete
  5. Repository Tests - Comprehensive test coverage (7+ tests)
  6. Factory Bean - Dependency injection registration

Critical Rules

Database Design (rules/database/SCHEMA.md)

SQL Requirements:

  • ❌ NO foreign key constraints (NEVER use REFERENCES or FOREIGN KEY)
  • ✅ Use TEXT for strings (NOT VARCHAR)
  • ✅ Include: id (UUID), created_at, updated_at, deleted_at
  • ✅ ALL indexes MUST have WHERE deleted_at IS NULL
  • ✅ Add soft delete index: WHERE deleted_at IS NOT NULL
  • ✅ Add update trigger for updated_at

Kotlin Requirements:

  • ✅ Table MUST extend UUIDTable (NOT Table)
  • ✅ Entity MUST implement Entity<Instant>
  • ✅ ALL queries MUST filter deletedAt.isNull()
  • ❌ NO !! operators (forbidden by pre-commit hooks)
  • ✅ Soft delete only (set deletedAt, never hard delete)

Workflow

Step 1: Create SQL Migration

Location: database-migration/sql/{number}-{description}.sql

-- ============================================================================
-- Description: [Describe what this migration does]
-- Table: {table_name}
-- ============================================================================

CREATE TABLE {table_name} (
    -- Primary key (REQUIRED)
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),

    -- Business columns
    name TEXT NOT NULL,
    email TEXT,
    status TEXT DEFAULT 'active',
    user_id UUID,
    count INTEGER DEFAULT 0,
    is_active BOOLEAN DEFAULT true,
    metadata JSONB,

    -- Standard timestamps (REQUIRED)
    created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP,
    deleted_at TIMESTAMP
);

-- Unique index (allows duplicate soft-deleted records)
CREATE UNIQUE INDEX idx_{table_name}_email_unique
    ON {table_name}(email) WHERE deleted_at IS NULL;

-- Foreign key index (NO FK constraint, just index)
CREATE INDEX idx_{table_name}_user_id
    ON {table_name}(user_id) WHERE deleted_at IS NULL;

-- Soft delete index (REQUIRED)
CREATE INDEX idx_{table_name}_deleted_at
    ON {table_name}(deleted_at) WHERE deleted_at IS NOT NULL;

-- Update trigger (REQUIRED)
CREATE TRIGGER update_{table_name}_updated_at
BEFORE UPDATE ON {table_name}
FOR EACH ROW
EXECUTE FUNCTION update_updated_at();

Critical:

  • Use TEXT not VARCHAR
  • NO REFERENCES or FOREIGN KEY
  • ALL indexes have WHERE clause
  • Soft delete index required
  • Update trigger required

Step 2: Run Migration

./gradlew :app:module-repository:flywayMigrate

Verify success before proceeding.

Steps 3-10: Kotlin Implementation

See kotlin-templates.md for all Kotlin code templates (Table, Entity, Repository, Factory Bean, Tests).

Follow this order:

  1. Step 3 — Table object (extends UUIDTable, use text() not varchar())
  2. Step 4 — Entity data class (implements Entity<Instant>)
  3. Step 5 — Constants/Enums (if needed)
  4. Step 6 — Repository interface
  5. Step 7 — Repository implementation (db.primary for writes, db.replica for reads, ALWAYS filter deletedAt.isNull())
  6. Step 8 — Factory bean registration
  7. Step 9 — Repository tests (minimum 7 tests, must include soft delete verification)
  8. Step 10 — Run tests: ./gradlew test

Common Mistakes to Avoid

See examples.md for common mistakes and anti-patterns.

Success Criteria

✅ SQL migration runs successfully ✅ Uses TEXT (not VARCHAR) ✅ NO foreign key constraints ✅ All indexes have WHERE clause ✅ Kotlin Table extends UUIDTable ✅ Entity implements Entity<Instant> ✅ All queries filter deletedAt.isNull() ✅ No !! operators ✅ Soft delete only (no hard delete) ✅ Factory bean registered ✅ All 7+ tests pass

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Creates RPC-style endpoint following layered architecture (Controller → Manager → Repository). Use when creating new API endpoints or CRUD operations.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

c0x12c/ai-toolkit1092026년 6월 18일 업데이트

Write blog posts, guides, tutorials, and long-form content. Sounds like a real person, not AI. Use when the user wants polished written content.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

c0x12c/ai-toolkit1092026년 6월 18일 업데이트

Design RPC-style APIs with layered architecture (Controller → Manager → Repository). Use when creating new API endpoints, designing API contracts, or reviewing API patterns.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

c0x12c/ai-toolkit1092026년 6월 18일 업데이트

Run a structured brainstorm session for startup ideas. Takes a theme or problem and generates ideas with quick gut-checks. Use when the user wants to explore a space or generate new ideas.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

c0x12c/ai-toolkit1092026년 6월 18일 업데이트

Run real browser QA with Playwright. Use when testing a frontend feature, verifying UI before PR, smoke testing after deploy, or investigating reported visual bugs.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

c0x12c/ai-toolkit1092026년 6월 18일 업데이트

CI/CD pipeline patterns for GitHub Actions, PR automation, and deployment workflows. Use when setting up CI, fixing broken pipelines, automating PR checks, or configuring deployment.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

c0x12c/ai-toolkit1092026년 6월 18일 업데이트

c0x12c의 스킬 모두 보기

이 스킬의 문제 신고