OpenAI & ChatGPT · Foto: Kevin Rheese, CC BY 2.0
Database Migrations taste
Zuletzt aktualisiert:
Typ
Prompt
Lizenz
CC0-1.0 (Public Domain)
Anwendungsfeld
Prompt-Bibliothek
Voraussetzungen
Keine besonderen — direkt loslegen.
Regelwerk für sichere, downtime-freie Datenbank-Migrationen nach dem Expand-Contract-Muster.
Der Prompt
# Database Migrations taste
- Keep every schema change in a versioned migration file committed next to the code that needs it. Confidence: 0.95
- Write migrations in plain SQL rather than ORM-generated diffs you have not read. Confidence: 0.80
- Never edit a migration that has already run in a shared environment; add a new one instead. Confidence: 0.95
- Use the expand and contract pattern: add the new column, backfill, switch reads, then drop the old column in a later release. Confidence: 0.90
- Make every migration safe to run while the previous app version is still serving traffic. Confidence: 0.90
- Add new columns as nullable or with a constant default to avoid long table rewrites. Confidence: 0.85
- Create indexes on large Postgres tables with CREATE INDEX CONCURRENTLY outside a transaction. Confidence: 0.90
- Set a short lock_timeout and statement_timeout at the top of each migration. Confidence: 0.85
- Run large backfills as batched background jobs, not inside the migration itself. Confidence: 0.90
- Keep one logical change per migration so failures are easy to read and retry. Confidence: 0.80
- Name migration files with a UTC timestamp prefix and a short verb phrase like 20261017_add_orders_status. Confidence: 0.75
- Prefer forward-only migrations and fix mistakes with a new migration instead of relying on down scripts. Confidence: 0.70
- Run migrations as a separate deploy step before the new application code starts. Confidence: 0.85
- Test every migration in CI against a fresh database and against a copy of production-sized data. Confidence: 0.80
- Add foreign keys and check constraints as NOT VALID first, then validate them in a separate step. Confidence: 0.80
- Rename columns and tables only through a view or dual-write period, never in a single step. Confidence: 0.75
- Store the applied migration history in the database and fail the deploy if it has drifted. Confidence: 0.85
- Review migrations as carefully as application code, with the generated SQL visible in the pull request. Confidence: 0.90
- Keep seed and fixture data out of schema migrations. Confidence: 0.80
So nutzt du es
Den Prompt-Text kopieren (Button oben) und als System-Prompt bzw. erste Nachricht in ChatGPT, Claude oder einem lokalen Modell einfügen. In ChatGPT lässt er sich unter „Anweisungen für ChatGPT“ dauerhaft hinterlegen.
Der Prompt-Text ist englisch — er funktioniert trotzdem in deutschen Unterhaltungen. Für deutsche Antworten einfach am Ende ergänzen: „Antworte auf Deutsch.“
Im Detail
Dieser Prompt macht aus der KI einen vorsichtigen Datenbank-Ingenieur: Jede Schemaänderung landet als versionierte, von Hand lesbare SQL-Migration im Code statt als ungeprüfter ORM-Diff, und bereits ausgeführte Migrationen werden nie mehr bearbeitet, sondern durch neue ersetzt. Zentrale Idee ist das Expand-Contract-Muster – neue Spalte anlegen, befüllen, Lesezugriffe umstellen, alte Spalte erst später löschen –, damit alte und neue App-Version parallel laufen können. Dazu kommen Postgres-Kniffe wie CREATE INDEX CONCURRENTLY außerhalb von Transaktionen und kurze lock_timeout/statement_timeout-Werte. Lohnt sich für Teams, die Schemaänderungen in laufende Produktionssysteme mit Continuous Deployment einspielen und Downtime oder gesperrte Tabellen vermeiden müssen.
Praxis-Tipp
Als System-Prompt einsetzen, bevor die KI eine Migration schreibt, z. B.: „Erstelle eine Migration, die der users-Tabelle (50 Mio. Zeilen, Postgres) eine Pflichtspalte email hinzufügt, ohne die Tabelle zu sperren.“
Siehe auch
Lizenz & Quelle
- Lizenz: CC0-1.0 (Public Domain)
- Quelle: awesome-chatgpt-prompts (GitHub)
So einfach geht’s
- 01
Anrufen oder schreiben
Anruf, WhatsApp oder Formular. Die Ersteinschätzung am Telefon ist kostenlos.
- 02
Termin oder Fernhilfe
Ich komme zu Ihnen oder helfe per Fernhilfe am Bildschirm. Den Kostenrahmen erfahren Sie, bevor ich anfange.
- 03
Erledigt, bezahlt wird danach
Es läuft, und Sie wissen, wie es geht. Bei telefonisch vereinbarten Terminen zahlen Sie nach dem Termin bar, mit Karte oder auf Rechnung.
Inhalt ansehen (database-migrations-taste.txt)
Lade …
Erfahrungen & Kommentare.
Funktioniert der Prompt bei Ihnen? Tipps, Stolperfallen, Varianten — teilen Sie es mit der Community.
Lade Kommentare …
Passt dazu.
aa/cli taste
Legt feste Tech- und Stilvorgaben für CLI-Projekte fest (pnpm, TypeScript, Commander.js, klare Ordnerstruktur).
Accessibility Auditor
Lässt die KI als Accessibility-Experte auf WCAG-2.2- und Section-508-Konformität prüfen.
Act as a Senior Codebase Auditor & Tech Debt Refactorer
Lässt die KI wie ein Senior-Engineer Altcode auf toten Code, Duplikate und unnötige Komplexität prüfen.
