database-migrations
БесплатноБез исполняемых скриптовНе проверенCreate, manage, and apply database migrations using Doctrine ORM (MySQL for this service). Use when modifying entities, adding fields, managing database…
Об этом скилле
Database Migrations Skill
Context (Input)
- New entity needs database persistence
- Existing entity requires schema changes (add/modify/remove fields)
- Repository implementation needed
- Database schema validation fails
- Need to set up indexes for performance
Task (Function)
Create entities with XML mapping and repositories following hexagonal architecture and relational database best practices (Doctrine ORM, MySQL).
Success Criteria: make setup-test-db runs without errors, schema validates, all tests pass.
Core Principles
Domain-Driven Design
- Entities: Domain layer (
{Context}/Domain/Entity/) - Repository Interfaces: Domain layer (
{Context}/Domain/Repository/) - Repository Implementations: Infrastructure layer (
{Context}/Infrastructure/Repository/) - XML Mappings: Infrastructure concern (
config/doctrine/)
See: implementing-ddd-architecture for DDD patterns.
Doctrine ORM (MySQL)
- Use XML mappings for all entity metadata (not annotations/attributes)
- Define indexes in XML for performance
- Use custom types (ULID, DomainUuid) for identifiers
- Schema updates applied via Doctrine migration/ORM commands
Note: Examples inherited from the template show MongoDB/ODM structures. In this project use
.orm.xmlmappings and Doctrine ORM migrations instead of ODM commands.
Quick Start
Creating a New Entity
Step 1: Create Entity (Domain Layer)
// src/Core/{Context}/Domain/Entity/{Entity}.php
namespace App\Core\{Context}\Domain\Entity;
final class Customer
{
public function __construct(
private string $id,
private string $name,
private string $email,
private \DateTimeImmutable $createdAt
) {}
// Getters only - no setters (immutability)
}
Step 2: Create XML Mapping
<!-- config/doctrine/Customer.orm.xml -->
<entity name="App\Core\Customer\Domain\Entity\Customer" repository-class="App\Core\Customer\Infrastructure\Repository\CustomerRepository">
<id name="id" type="domain_uuid"/>
<field name="name" type="string" length="255"/>
<field name="email" type="string" length="255" unique="true"/>
<field name="createdAt" column="created_at" type="datetime_immutable"/>
</entity>
Step 3: Configure API Platform
# config/api_platform/resources/customer.yaml
App\Core\Customer\Domain\Entity\Customer:
shortName: Customer
operations:
get_collection: ~
get: ~
post: ~
Step 4: Update Schema
make cache-clear
docker compose exec php bin/console doctrine:schema:validate
See: entity-creation-guide.md for complete workflow.
Modifying Existing Entities
- Update Entity Class (add/modify fields)
- Update XML Mapping (add field definitions)
- Clear Cache:
make cache-clear - Validate Schema:
docker compose exec php bin/console doctrine:schema:validate
See: entity-modification-guide.md
Creating Repositories
Step 1: Define Interface (Domain)
// Domain/Repository/CustomerRepositoryInterface.php
interface CustomerRepositoryInterface
{
public function save(Customer $customer): void;
public function findById(string $id): ?Customer;
}
Step 2: Implement (Infrastructure)
// Infrastructure/Repository/CustomerRepository.php
final class CustomerRepository implements CustomerRepositoryInterface
{
public function __construct(
private readonly DocumentManager $documentManager
) {}
public function save(Customer $customer): void
{
$this->documentManager->persist($customer);
$this->documentManager->flush();
}
}
Step 3: Register in services.yaml
App\Core\Customer\Domain\Repository\CustomerRepositoryInterface:
alias: App\Core\Customer\Infrastructure\Repository\CustomerRepository
Database-Specific Features (Doctrine ORM/MySQL)
Custom Types
| Type | Usage | Purpose |
|---|---|---|
ulid |
Primary/foreign keys | Sortable, time-ordered identifiers |
domain_uuid |
Domain identifiers | Standard UUID format (RFC 4122) |
<id name="id" type="domain_uuid"/>
<field name="token" type="ulid"/>
Indexes & Constraints
- Use
unique=\"true\"on fields or<unique-constraint>elements for uniqueness (e.g., email). - Add
<indexes>with<index name=\"idx_email\" columns=\"email\"/>for frequent lookups. - Always index columns used in filters/sorting (email, token, foreign keys, timestamps).
Relationships & Value Objects
- Model associations with Doctrine relations (
one-to-one,one-to-many,many-to-many). - Persist value objects as simple fields; avoid
Установить database-migrations в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл database-migrations?
Create, manage, and apply database migrations using Doctrine ORM (MySQL for this service). Use when modifying entities, adding fields, managing database schema changes, creating repositories, or troubleshooting database issues.
Как установить скилл database-migrations?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл database-migrations запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic