Logo vun Doctrine Migrations

Doctrine Migrations

Communautéit
fatonh
doctrine-migrations

Use when changing the database schema in Symfony — generating Doctrine migrations, writing reversible up()/down(), data migrations, and deploy-safe (zero-downtime) changes. Use when the task mentions migration, schema change, ALTER TABLE, or doctrine:migrations.

Iwwersiicht

Editeurfatonh
Repositorysymfony-skills
Skill-Nummdoctrine-migrations
Stären
36
Forks
3
Matgeliwwert Fichieren
Nëmmen Instruktiounen
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • Alles an den Instruktiounen

    Alles, wat de Modell brauch, steet an den Instruktiounen — keng zousätzlech Dateien ze synchroniséieren.

  • Open Source

    Vum fatonh op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Doctrine Migrations an TypingMind, fir e mat all LLM ze benotzen, oder füügt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vun GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier hei drënner an a bestätegt.
    https://github.com/fatonh/symfony-skills/tree/main/skills/doctrine-migrations
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill afügen → Vu GitHub-URL, pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an de Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/fatonh/symfony-skills.git /tmp/symfony-skills
mkdir -p .claude/skills
cp -r /tmp/symfony-skills/skills/doctrine-migrations .claude/skills/doctrine-migrations
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Doctrine Migrations an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Doctrine Migrations automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Doctrine Migrations net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Keys.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

Doctrine Migrations (Symfony)

Generate, don't hand-write the schema diff

After changing entity mapping, generate the migration from the diff, then review it:

bash
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.

Anatomy of a migration

php
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.
  • One logical change per migration — don't bundle unrelated DDL.
  • Keep migrations immutable once merged/deployed. Never edit a migration that has run anywhere; write a new one.

Zero-downtime / deploy-safe changes

When the app is running during deploy, schema changes must be backward compatible with the currently deployed code.

ChangeSafe?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
php
// 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.

Data migrations

Transforming rows belongs in up() too, but keep it set-based SQL, not entity hydration (the entity classes may not match the historical schema):

php
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.

Conventions

  • One migration file per PR that changes the schema; commit it alongside the entity change.
  • Verify up() then down() then up() runs clean locally before pushing.
  • Name migrations by what they do (via getDescription()), since the class name is just a timestamp.
  • In CI, fail the build if make:migration would produce a non-empty diff (schema and entities are out of sync).
bash
php bin/console doctrine:migrations:migrate --dry-run   # print SQL without executing
php bin/console doctrine:schema:validate                 # entities ⇄ DB in sync?

Gotchas

  • Agent runs doctrine:schema:update --force instead of generating a migration — always use make:migration + migrate.
  • Agent leaves down() empty or throwing — make it reverse up().
  • Agent adds a NOT NULL column with no default to a populated table — add nullable, backfill, then enforce NOT NULL.
  • Agent edits an already-deployed migration — migrations are immutable; write a new one.
  • Agent imports entity classes inside a migration — use raw SQL; entities don't match historical schemas.
  • Agent renames a column in one step during a live deploy — use expand/contract.
  • Agent creates an index on a big Postgres table without CONCURRENTLY (+ isTransactional(): false) — it locks the table.
  • Agent bundles several unrelated schema changes into one migration — keep them separate.

Heefeg gestallte Froen

Wat mécht de KI-Skill Doctrine Migrations?

Use when changing the database schema in Symfony — generating Doctrine migrations, writing reversible up()/down(), data migrations, and deploy-safe (zero-downtime) changes. Use when the task mentions migration, schema change, ALTER TABLE, or doctrine:migrations.

Firwat Doctrine Migrations op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Doctrine Migrations besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt amplaz vun engem Abonnement pro Benotzerplaz. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Doctrine Migrations an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/fatonh/symfony-skills/tree/main/skills/doctrine-migrations an. TypingMind liest d'Datei SKILL.md an installéiert de Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Doctrine Migrations benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Doctrine Migrations benotzen?

Esou vill Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Doctrine Migrations domat benotzen – GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama a méi – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Doctrine Migrations gratis?

Jo. De Skill gëtt vum fatonh ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbaart Pak vun Instruktiounen, dat engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt en nokënnt a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a keng Lafzäitëmfeld a funktionéiere mat all Modell.

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇