db-legacy-migration-agent
db-legacy-migration-agent
레거시 관계형 DB 스키마(DB2, Oracle PL/SQL, MySQL, MSSQL)를 파싱하고, 생성된 Prisma ORM 스키마와 TypeScript 쿼리 헬퍼를 사용하여 PostgreSQL로 자동 트랜스파일하는 CLI 및 MCP 서버입니다.
목차
Related MCP server: db-mcp
개요
레거시 엔터프라이즈 시스템은 종종 벤더별 SQL 방언(Oracle PL/SQL, IBM DB2, Microsoft T-SQL)에 의존하는데, 이는 상당한 수동 작업 없이는 최신 스택으로 직접 마이그레이션할 수 없습니다. 이 도구는 구조 변환 단계를 자동화합니다:
입력 | 출력 |
|
|
PL/SQL | 최선의 TypeScript 등가물 |
레거시 DDL의 모든 조합 | TypeScript Prisma Client 쿼리 헬퍼 |
전체 DDL 파일 | 정밀도 손실 분석이 포함된 검증 보고서 |
아키텍처
src/
├── parser/
│ └── sql-transpiler.ts # DDL lexer/parser + Prisma/TS code generator
├── engine/
│ └── schema-validator.ts # Precision-loss & semantic mismatch validator
├── mcp/
│ └── server.ts # MCP server (stdio transport)
└── cli.ts # Commander.js interactive CLI
tests/
└── transpiler.test.ts # Jest unit tests (40+ assertions)핵심 모듈
src/parser/sql-transpiler.ts
전체 트랜스파일 파이프라인을 담당합니다:
토큰화 — 주석 제거, 공백 정규화, 따옴표로 묶인 식별자 처리
DDL 파싱 — 열, 제약 조건, FK, 인덱스가 포함된
CREATE TABLEPL/SQL 파싱 — 매개변수 방향이 포함된
CREATE [OR REPLACE] PROCEDURE/FUNCTION타입 매핑 —
{ prismaType, postgresType }에 대한 40개 이상의 레거시 타입 매핑Prisma 스키마 생성 —
@@map,@db.*어노테이션, 복합 PK, FK 관계TypeScript 쿼리 생성 —
PrismaClient를 사용한 CRUD 헬퍼PL/SQL 구조 변환 —
BEGIN/END,IF/THEN/ELSIF,FOR/WHILE LOOP,:=,DBMS_OUTPUT
src/engine/schema-validator.ts
트랜스파일된 테이블 정의에 대해 규칙 엔진을 실행하고 구조화된 ValidationIssue 레코드를 생성합니다:
치명적(Critical) — 데이터 손실이 보장됨 (예:
BIGINT_OVERFLOW,NULLABLE_PK)경고(Warning) — 검토가 필요한 의미론적 불일치 (예:
ORACLE_DATE_HAS_TIME,XMLTYPE_NO_NATIVE)정보(Info) — 정보성 메모 (예:
LOB_TO_TEXT,DB2_GRAPHIC_TYPE)
src/mcp/server.ts
stdio 전송을 통해 세 가지 도구를 노출하는 MCP 서버:
도구 | 설명 |
| 전체 파싱 + 생성: AST, Prisma 스키마, TS 쿼리 반환 |
|
|
| 구조화된 또는 텍스트 검증 보고서 반환 |
시작하기
사전 요구 사항
Node.js ≥ 18
npm ≥ 9
설치
npm install빌드
npm run buildCLI 전역 링크 (선택 사항)
npm link
db-migrate --helpCLI 명령어
transpile <file>
DDL 파일을 파싱하고 출력 디렉토리에 schema.prisma, queries.ts, ast.json을 생성합니다.
npx ts-node src/cli.ts transpile ./examples/oracle_hr.sql \
--dialect oracle \
--out ./output옵션:
플래그 | 기본값 | 설명 |
|
| 소스 방언: |
|
| 출력 디렉토리 |
| — | TypeScript 쿼리 생성 건너뛰기 |
| — | 트랜스파일 후 검증 건너뛰기 |
validate <file>
타입 매핑을 검증하고 구조화된 보고서를 출력합니다.
npx ts-node src/cli.ts validate ./examples/oracle_hr.sql \
--dialect oracle \
--format text옵션:
플래그 | 기본값 | 설명 |
|
| 소스 방언 |
|
|
|
| — | 경고가 발견되면 종료 코드 1 (CI 파이프라인용) |
종료 코드:
코드 | 의미 |
| 문제 없음 또는 정보만 있음 |
| 경고 발견 ( |
| 치명적 문제 발견 |
parse-inline <ddl>
빠른 테스트 — 명령줄에서 DDL 문자열을 직접 파싱합니다.
npx ts-node src/cli.ts parse-inline \
"CREATE TABLE T (ID NUMBER(10) NOT NULL, NAME VARCHAR2(100), CONSTRAINT PK_T PRIMARY KEY (ID));"mcp
AI 어시스턴트 통합을 위해 stdio를 통해 MCP 서버를 시작합니다.
npx ts-node src/cli.ts mcpMCP 서버
MCP 서버는 모든 MCP 호환 AI 어시스턴트(예: Claude Desktop, IBM Bob)에 등록할 수 있습니다.
도구: parse_legacy_ddl
{
"tool": "parse_legacy_ddl",
"input": {
"ddl": "CREATE TABLE EMPLOYEES (...);",
"dialect": "oracle",
"include_typescript": true
}
}반환: 전체 AST, Prisma 스키마, TypeScript 쿼리, 경고.
도구: generate_prisma_schema
{
"tool": "generate_prisma_schema",
"input": {
"ddl": "CREATE TABLE EMPLOYEES (...);",
"dialect": "oracle"
}
}반환: schema.prisma 콘텐츠를 일반 문자열로 반환.
도구: validate_type_mapping
{
"tool": "validate_type_mapping",
"input": {
"ddl": "CREATE TABLE EMPLOYEES (...);",
"dialect": "oracle",
"format": "json"
}
}반환: 구조화된 ValidationReport JSON 또는 사람이 읽을 수 있는 텍스트.
타입 매핑 참조
레거시 타입 | Prisma 타입 | PostgreSQL 타입 | 참고 사항 |
|
|
| 정밀도 보존 |
|
|
| 스케일 보존 |
|
|
| 32비트에 적합 |
|
|
| 64비트에 적합 |
|
|
| ⚠ BigInt 오버플로우 발생 |
|
|
| |
|
|
| 고정 길이 패딩 |
|
|
| ℹ 별도의 LOB 세그먼트 없음 |
|
|
| ℹ 인라인 저장 |
|
|
| ⚠ Oracle DATE는 시간 포함 |
|
|
| |
|
|
| |
|
|
| ⚠ 단정밀도 |
|
|
| |
|
|
| ⚠ Prisma 네이티브 XML 없음 |
|
|
| |
|
|
| |
|
|
| |
|
|
|
검증 규칙
코드 | 심각도 | 트리거 | 권장 사항 |
| 경고 | 스케일이 없는 | 명시적 스케일 추가 |
| 치명적 |
|
|
| 경고 |
|
|
| 정보 |
| LOB 스트리밍 API 업데이트 |
| 정보 |
| 1GB 초과 값에는 lo API 사용 |
| 경고 | Oracle | 시간이 필요하면 |
| 경고 |
| TZ 변환 로직 확인 |
| 경고 |
|
|
| 정보 |
| 무제한에는 |
| 경고 |
| XML 작업에는 |
| 정보 | DB2 | UTF-8 트랜스코딩 확인 |
| 경고 | 테이블에 PK 없음 |
|
| 치명적 | PK 열이 nullable로 파싱됨 | 소스 DDL 수정 |
프로젝트 구조
db-legacy-migration-agent/
├── src/
│ ├── parser/
│ │ └── sql-transpiler.ts # Type mappings, DDL parser, Prisma & TS generators
│ ├── engine/
│ │ └── schema-validator.ts # Rule engine, ValidationReport, formatter
│ ├── mcp/
│ │ └── server.ts # MCP server with 3 tools
│ └── cli.ts # Commander.js CLI entrypoint
├── tests/
│ └── transpiler.test.ts # Jest unit tests
├── dist/ # Compiled output (after `npm run build`)
├── output/ # Generated files (schema.prisma, queries.ts, ast.json)
├── package.json
├── tsconfig.json
└── README.md테스트 실행
# Run all tests
npm test
# With coverage
npm test -- --coverage
# Watch mode
npm test -- --watch예상 출력: 트랜스파일러 파싱, 타입 매핑, PL/SQL 변환, 검증기 규칙에 걸쳐 40개 이상의 어서션.
기여하기
저장소를 포크하고 클론합니다
npm install을 실행하여 의존성을 설치합니다src/에 기능/수정 사항을 추가합니다tests/에 테스트를 추가하거나 업데이트합니다PR을 제출하기 전에
npm test와npm run typecheck를 실행합니다
라이선스
MIT
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceAn extensible MCP server for database operations that supports PostgreSQL for managing schemas, tables, data, and user permissions. It features automatic migration recording for DDL changes and integrates with various AI-powered editors like Cursor, Zed, and Claude Code.222MIT
- AlicenseAqualityCmaintenanceA lightweight MCP server for relational databases, enabling dynamic connections to PostgreSQL and MySQL, SQL execution, and transaction control.7511MIT
- AlicenseNot gradedqualityDmaintenanceMCP server that analyzes TypeScript/Prisma projects, builds dependency graphs, and protects against dangerous modifications and silent regressions.141MIT
- AlicenseAqualityAmaintenanceMCP server that reads your database schema from SQL DDL, Prisma, Drizzle, TypeORM, or SQLAlchemy, generates a Mermaid ER diagram, and writes it into your documentation, with drift detection to keep diagrams up-to-date.51MIT
Related MCP Connectors
MCP server for managing Prisma Postgres.
MCP server for interacting with the Supabase platform
Butterbase MCP server — manage your backend: schemas, auth, functions, storage, RAG, deploys.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/felipeassis10/db-legacy-migration-agent'
If you have feedback or need assistance with the MCP directory API, please join our Discord server