一键导入
database-migration
Manage database migrations and Better Auth schema. Use when adding tables, modifying schema, running migrations, or resetting the database.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Manage database migrations and Better Auth schema. Use when adding tables, modifying schema, running migrations, or resetting the database.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | database-migration |
| description | Manage database migrations and Better Auth schema. Use when adding tables, modifying schema, running migrations, or resetting the database. |
| allowed-tools | Read, Bash, Grep |
Manage PostgreSQL database, Better Auth schema, and GORM AutoMigrate.
Jeder Bounded Context unter backend/internal/<ctx>/ hat seine eigene infrastructure/persistence/registry.go mit einer Entities() []any Funktion. Der Composition Root sammelt die Listen ein:
// backend/internal/<ctx>/infrastructure/persistence/registry.go
func Entities() []any {
return []any{&gormNewEntity{}} // GORM-tagged twin der pure-domain Entity
}
// backend/internal/composition/composition.go (runAutoMigrations)
entities := []any{}
entities = append(entities, statspersist.Entities()...)
entities = append(entities, <newctx>persist.Entities()...) // ← neu
Es gibt keine zentrale Registry mehr. cmd/server/main.go ruft nur composition.Build auf — die Migrationen laufen automatisch beim Backend-Start.
just db-up
just db-down
just db-reset
Better Auth uses these tables (auto-created via migration):
user - User accountssession - Active sessionsaccount - OAuth/credential accountsverification - Email verification tokensjust db-migrate
Or manually:
cd frontend && bunx dotenv-cli -e .env.local -- bunx @better-auth/cli@latest migrate --config src/shared/lib/auth-server/auth.ts --yes
cd frontend && bunx dotenv-cli -e .env.local -- bunx @better-auth/cli@latest generate --config src/shared/lib/auth-server/auth.ts
docker exec nextgopg-db-1 psql -U postgres -d nextgopg
docker exec nextgopg-db-1 psql -U postgres -d nextgopg -c "\dt"
docker exec nextgopg-db-1 psql -U postgres -d nextgopg -c "\d user"
docker exec nextgopg-db-1 psql -U postgres -d nextgopg -c "SELECT * FROM \"user\""
postgres://postgres:postgres@localhost:5432/nextgopg
Set in frontend/.env.local:
DATABASE_URL=postgres://postgres:postgres@localhost:5432/nextgopg
Run Better Auth migration:
cd frontend && DATABASE_URL="postgres://postgres:postgres@localhost:5432/nextgopg" bunx @better-auth/cli migrate -y
Start the database:
just db-up
just db-reset
just db-migrate
Generate TypeScript API client from Swagger/Go comments. Use when updating API endpoints, adding new routes, or regenerating the frontend API client after backend changes.
Generate full-stack features. Backend = hand-written bounded-context aggregates (DDD); frontend = FSD slices with HydrationBoundary. Use when creating new features, adding CRUD operations, or scaffolding new pages.
Access local technical documentation before searching the internet. Use FIRST when researching any tech stack question.
Create and manage authentication pages with server-side session handling. Use when adding login, register, or protected pages WITHOUT flicker/skeleton.
Server-Side + Client-Side Data Fetching with Orval + TanStack Query HydrationBoundary Pattern. ALWAYS use Orval - NEVER manual fetch()!
Feature-Sliced Design architecture for frontend. Use when creating new features, slices, or understanding the FSD layer structure.