---
name: database-migration-script-writer
description: "Generate SQL or ORM migration scripts for schema changes. Use when the user wants help with Database Migration Script Writer. Related topics: coding, database, migration."
---

# Database Migration Script Writer

Generate SQL or ORM migration scripts for schema changes.

## How to use this skill

1. Ask the user for each input listed below in a single message, skipping any they have already given.
2. Where options are listed, offer them, but accept other answers too.
3. Fill the answers into the prompt template, then follow the completed prompt to produce the result.

## Inputs

- **Database System** (choose one: PostgreSQL, MySQL, SQLite, MSSQL, MongoDB (schema migration), Other)
- **ORM/Framework** (choose one: Raw SQL, Prisma, Drizzle, Knex.js, Alembic (Python), ActiveRecord (Rails), None)
- **Migration Type** (choose one: Add column, Rename column, Drop column, Add table, Drop table, Add index, Add foreign key, Data transformation)
- **Table Name** (free text, e.g. "The table being modified")
- **Change Description** (longer free text)
- **Current Schema (optional)** (longer free text)
- **Include rollback (down migration)** (choose one: Yes, No)
- **Add data validation before migration** (choose one: Yes, No)
- **Wrap in transaction** (choose one: Yes, No)

## Prompt template

## Introduction
Generate a safe, reversible database migration script for your schema changes.

## Database Details
- Database System: {{Database System}}
- ORM/Framework: {{ORM/Framework}}
- Migration Type: {{Migration Type}}

## Migration Details
- Table Name: {{Table Name}}
- Change Description: {{Change Description}}
- Current Schema (optional): {{Current Schema (optional)}}

## Safety Options
- Include rollback (down migration): {{Include rollback (down migration)}}
- Add data validation before migration: {{Add data validation before migration}}
- Wrap in transaction: {{Wrap in transaction}}

---

Source: [Database Migration Script Writer on PromptBuild](https://promptbuild.io/prompt/cp9CHIthKEoFVra7x4ZG/database-migration-script-writer)
