Database migration script generator prompt

Describe a schema change and get a migration script with up and down steps, plus a note on any data-loss risk.

بواسطة ‪Ahmed Eid‬‏0 نسخة

متى تستخدم هذا البرومبت

  • When adding, renaming, or removing a column or table.
  • When backfilling data as part of a schema change.
  • When writing a rollback plan before a risky migration.

نص البرومبت

Write a {{language}} database migration that: {{focus}}. Target: {{framework}}. Include both the up and down migration, and note any risk of data loss.

{{CLIPBOARD}}
{{language}}{{focus}}{{framework}}{{CLIPBOARD}}

الكتلة {{CLIPBOARD}} تُستبدل تلقائياً بما نسخته قبل الضغط على «نسخ».

كيف تستخدمه

  1. انسخ البرومبت بالزر أو املأ المتغيرات أولاً.
  2. الصقه في ChatGPT أو Claude أو Gemini.
  3. عدّل النتيجة أو أعد الطلب بتغيير المتغيرات.

مثال على النتيجة

-- Up
ALTER TABLE users ADD COLUMN last_login_at TIMESTAMP;

-- Down
ALTER TABLE users DROP COLUMN last_login_at;

Risk: the down migration is destructive, any last_login_at data written after the up migration will be permanently lost on rollback.

نصائح للاستخدام

  • Name your migration tool (Prisma, Rails, Alembic, Flyway, raw SQL) for the correct file format.
  • Always review the down migration yourself before running it against production data.
  • For renames or type changes, ask specifically about backward compatibility during a rolling deploy.

أسئلة شائعة

Is it safe to run the down migration on production?
Not automatically; the prompt flags data-loss risk, but you should test rollbacks on a staging copy first.
Can it write a data backfill migration, not just schema changes?
Yes, describe the backfill logic needed in the focus field and it will include the data-transformation step.

برومبتات ذات صلة

Generate a GraphQL Schema from a Description

Describe your data and operations in plain English and get a complete, documented GraphQL schema.

Design a GraphQL schema (types, queries, mutations) for: {{focus}}. Use {{language}} conventions and include field-level descriptions. {{CLIPBOARD}}

{{focus}}{{language}}{{CLIPBOARD}}

Generate Realistic Mock Data for Testing

Get realistic, varied mock data, including edge cases, matched to your schema, ready to seed a test database.

Generate {{focus}} realistic mock/test data records in {{language}} format for this schema or type, with varied and edge-case values. {{CLIPBOARD}}

{{focus}}{{language}}{{CLIPBOARD}}

Explain What This Legacy Code Actually Does

Paste unfamiliar or legacy code and get a plain-language walkthrough, with dead code and possible bugs flagged.

Walk through this {{language}} code line by line and explain what it does, in plain language. Flag anything that looks like dead code, a workaround, or a potential bug. {{CLIPBOARD}}

{{language}}{{CLIPBOARD}}

Generate a Dockerfile for Your App

Get a secure, optimized Dockerfile tailored to your language and framework, ready to build and run.

Write a production-ready Dockerfile for a {{language}} app using {{framework}}. Use multi-stage builds where useful, minimize image size, and run as a non-root user. Notes: {{focus}}. {{CLIPBOARD}}

{{language}}{{framework}}{{focus}}{{CLIPBOARD}}
المزيد في برمجة