Without migration, re-extract the current state of the DB into schema filesdoes.
bun run db:up-dev/db:down-devWhen run, extract-schema is automatically chained, so this skill only when manual extraction is needed is used.
Workflow
Step 1: Run schema extraction
cd api && bun run db:extract-schema
Step 2: Result summary
From the execution results, show the following 4 figures:
- Created: Newly created schema files
- Updated: Files updated because the DDL changed
- Unchanged: Files with no changes
- Deleted: Cleanup of schema files for tables deleted from the DB
Step 3: Details of changed files
If there are Updated or Created files:
- Show the list of changed files.
- Summarize the main changes (column additions/deletions, index changes, etc.).
Output file location
api/db/schema/{도메인}/{테이블명}.sql
The domain is automatically classified by the first _ part of the table name:
order_item.sql→schema/order/order_item.sqlcommon_file.sql→schema/common/common_file.sqlmember.sql→schema/member/member.sql
Extraction contents
- CREATE TABLE DDL (columns, types, defaults, NOT NULL)
- COMMENT ON TABLE / COLUMN (Korean comments)
- CREATE INDEX (including Partial Index WHERE clauses)
- PRIMARY KEY CONSTRAINT
When to use
- Syncing schema files after another developer has directly changed the DB
- When a mismatch between schema files and the actual DB state is suspected
- When you want to check only the DB structure without migration
- When generating schema files for the first time in a new project environment