mcpField
P
peach-db-extract-schema

peach-db-extract-schema

github.com/peachsolutionData & databases51 installs
Repository

About peach-db-extract-schema

A skill for extracting schema files from the database’s current state without running migrations. It summarizes file changes and supports keeping schema files aligned with the database.

Key features

  1. 01Extracts schema from current database
  2. 02Creates and updates SQL schema files
  3. 03Removes files for deleted tables
  4. 04Reports file and DDL changes
  5. 05Groups files by table-name prefix

Use cases

  1. 01Syncing files after direct database changes
  2. 02Checking suspected schema drift
  3. 03Inspecting structure without migrations
  4. 04Generating initial schema files

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/peachsolution/peach-harness --skill peach-db-extract-schema

After installing, type/peach-db-extract-schemain Claude Code to confirm it loaded.

Details

From the project README

DB 스키마 추출

마이그레이션 없이 DB의 현재 상태를 스키마 파일로 재추출한다.

bun run db:up-dev / db:down-dev 실행 시에는 extract-schema가 자동 체이닝되므로, 이 스킬은 수동 추출이 필요할 때만 사용한다.

워크플로우

1단계: 스키마 추출 실행
cd api && bun run db:extract-schema
2단계: 결과 요약

실행 결과에서 아래 4가지 수치를 보여준다:

  • Created: 새로 생성된 스키마 파일
  • Updated: DDL이 변경되어 갱신된 파일
  • Unchanged: 변경 없는 파일
  • Deleted: DB에서 삭제된 테이블의 스키마 파일 정리
3단계: 변경 파일 상세

Updated 또는 Created 파일이 있으면:

  • 변경된 파일 목록을 보여준다.
  • 주요 변경 내용(컬럼 추가/삭제, 인덱스 변경 등)을 요약한다.

출력 파일 위치

api/db/schema/{도메인}/{테이블명}.sql

도메인은 테이블명의 첫 번째 _ 앞 부분으로 자동 분류된다:

  • order_item.sql → schema/order/order_item.sql
  • common_file.sql → schema/common/common_file.sql
  • member.sql → schema/member/member.sql

추출 내용

  • CREATE TABLE DDL (컬럼, 타입, 기본값, NOT NULL)
  • COMMENT ON TABLE / COLUMN (한글 코멘트)
  • CREATE INDEX (Partial Index WHERE 절 포함)
  • PRIMARY KEY CONSTRAINT

사용 시점

  • 다른 개발자가 DB를 직접 변경한 후 스키마 파일 동기화
  • 스키마 파일과 실제 DB 상태 불일치 의심 시
  • 마이그레이션 없이 DB 구조만 확인하고 싶을 때
  • 새 프로젝트 환경에서 최초 스키마 파일 생성 시

Comments

Markdown supported