Skip to main content

database-migration

Modify PostgreSQL schemas, author or review Alembic migrations, and update SQLAlchemy persistence models. Not for query-only changes.

소스 정보

저장소
pumni/thread
최근 소스 활동
2026년 10월 5일 02:22
감지된 SKILL.md 언어
영어
스타
0
포크
0

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
name
database-migration
description
Modify PostgreSQL schemas, author or review Alembic migrations, and update SQLAlchemy persistence models. Not for query-only changes.
# Database Migration Skill ## Purpose Guide the creation, review, and verification of PostgreSQL schema changes and Alembic migrations while preserving data safety, reversibility, and system invariants. ## Trigger Conditions Use this skill when a task involves: - Creating, modifying, or testing Alembic migrations in `migrations/versions/`. - Modifying SQLAlchemy ORM models in `src/threads_platform/infrastructure/persistence/models.py`. - Altering database tables, columns, indexes, foreign keys, or check constraints. - Validating database schema synchronization (`alembic check`). ## Non-Trigger Conditions Do NOT use this skill for: - Pure domain entities in `src/threads_platform/domain/` with no schema alterations. - Read-only database queries or repository method additions that do not alter the table structure. - Local in-memory or file-based caching changes. ## Canonical References Inspect these sources before authoring schema changes: - `migrations/env.py` and existing revisions in `migrations/versions/`. - `src/threads_platform/infrastructure/persistence/models.py`. - `docs/ACCEPTANCE_AND_REVIEW.md` (Section 3: Data gate). - `docs/adr/0002-python-uv-postgresql.md`. - `scripts/windows_local_preflight.ps1` (disposable PostgreSQL test cluster). ## Invariants & Design Rules 1. **PostgreSQL is Authoritative:** Database constraints (unique, foreign key, check constraints) enforce business invariants at rest. 2. **Reversibility:** Every migration must implement a safe, functional `downgrade()` function where practically feasible. 3. **UTC Timestamps:** All timestamp columns must use timezone-aware UTC (`sa.DateTime(timezone=True)`). 4. **Index Discipline:** Add composite indexes for high-frequency queries, particularly WorkerJob claim queries, command leasing, and account status lookups. 5. **Secret Hygiene:** Never introduce columns that store plaintext tokens, passwords, private keys, or unredacted proxy credentials. ## Step-by-Step Procedure 1. **Inspect current schema:** Check existing migration files in `migrations/versions/` to determine the latest revision head and naming convention (`YYYYMMDD_NNNN_<slug>.py`). 2. **Update models:** Modify SQLAlchemy models in `src/threads_platform/infrastructure/persistence/models.py`. 3. **Generate/author revision:** Create the migration script in `migrations/versions/` with explicit `upgrade()` and `downgrade()` operations. 4. **Verify locally:** ```bash uv run alembic check uv run pytest tests/integration/test_*migration*.py ``` 5. **Run preflight:** On Windows, execute `powershell -NoProfile -File scripts/windows_local_preflight.ps1` to test the migration against a real disposable PostgreSQL instance.
GitHub에서 보기