/symfony-skills:doctrine-migrationsfrom symfony-skills
Generates and reviews Doctrine migrations in Symfony — schema diffs, reversible up()/down(), data migrations, and zero-downtime deploy-safe changes.
Ships in symfony-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
After changing entity mapping, generate the migration from the diff, then review it:
php bin/console make:migration # diffs entities vs DB, scaffolds up()/down()
php bin/console doctrine:migrations:migrate
Never edit the schema with doctrine:schema:update --force outside local throwaway work — it bypasses migration history. Always review the generated SQL before committing; the diff tool sometimes proposes destructive or reordering changes you didn't intend.
final class Version20260620120000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add status column to orders and index it';
}
public function up(Schema $schema): void
{
$this->addSql("ALTER TABLE orders ADD status VARCHAR(20) NOT NULL DEFAULT 'pending'");
$this->addSql('CREATE INDEX idx_orders_status ON orders (status)');
}
public function down(Schema $schema): void
{
$this->addSql('DROP INDEX idx_orders_status');
$this->addSql('ALTER TABLE orders DROP status');
}
}
down() must reverse up() exactly — don't leave it empty or throw. A migration you can't roll back is a deploy you can't undo.When the app is running during deploy, schema changes must be backward compatible with the currently deployed code.
| Change | Safe? | Do this |
|---|---|---|
| Add nullable column | ✅ | Single migration |
| Add NOT NULL column | ⚠️ | Add nullable → backfill → set NOT NULL (3 steps, often 2 deploys) |
| Rename column | ❌ | Add new → copy → deploy code using new → drop old |
| Drop column | ⚠️ | Deploy code that stops using it first, then drop |
| Add index on large table | ⚠️ | CREATE INDEX CONCURRENTLY (Postgres) — outside a transaction |
// Postgres concurrent index — must run outside the migration's wrapping transaction
public function up(Schema $schema): void
{
$this->addSql('CREATE INDEX CONCURRENTLY idx_orders_created_at ON orders (created_at)');
}
public function isTransactional(): bool
{
return false; // CONCURRENTLY can't run inside a transaction
}
The expand/contract pattern: expand the schema (additive, both old and new code work), deploy code, then contract (remove the old) in a later migration.
Transforming rows belongs in up() too, but keep it set-based SQL, not entity hydration (the entity classes may not match the historical schema):
public function up(Schema $schema): void
{
$this->addSql("UPDATE orders SET status = 'pending' WHERE status IS NULL");
$this->addSql('ALTER TABLE orders ALTER COLUMN status SET NOT NULL');
}
Don't use App\Entity\Order inside a migration — entities evolve, migrations are frozen in time. For heavy backfills that can't be one statement, prefer a separate idempotent console command run during deploy.
up() then down() then up() runs clean locally before pushing.getDescription()), since the class name is just a timestamp.make:migration would produce a non-empty diff (schema and entities are out of sync).php bin/console doctrine:migrations:migrate --dry-run # print SQL without executing
php bin/console doctrine:schema:validate # entities ⇄ DB in sync?
doctrine:schema:update --force instead of generating a migration — always use make:migration + migrate.down() empty or throwing — make it reverse up().NOT NULL column with no default to a populated table — add nullable, backfill, then enforce NOT NULL.CONCURRENTLY (+ isTransactional(): false) — it locks the table.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
PHP, Symfony, SQL, PostgreSQL
17 skills in this plugin
/api-platform-resourcesUse when exposing data through API Platform 4 — defining #[ApiResource], operations, DTO resources, state providers/processors, serialization groups, filters, and pagination. Use when the task mentions API Platform, ApiResource, state processor, or exposing an entity as a REST/GraphQL endpoint.
/bundle-organizationUse when structuring a Symfony project's src/ directory, organizing code into modules, configuring services, or deciding where a class belongs. Covers the modular monolith layout, service configuration, and config/ conventions for Symfony 7 (Flex, no app bundle).
/console-commandsUse when creating or refactoring Symfony console commands — never extends Command. On Symfony 8.1+ put #[AsCommand] on a method of a service class (even for a single command); on 7.x use the invokable attribute class. Also covers typed CLI inputs via value resolvers and #[MapInput] DTOs. Use when the task mentions console command, #[AsCommand], bin/console, #[Argument], #[Option], or a CLI task.
npx claudepluginhub fatonh/symfony-skills --plugin symfony-skillsOther plugins' skills for the same job