home/productivity/create-migration-prompt

Create Migration.prompt

GPTClaudeDeepSeek··232 copies·updated 2026-07-14
create-migration-prompt.prompt
---
mode: "agent"
tools: ['codebase', 'editFiles', 'usages', 'memory']
description: "Create a database migration file for a new feature or change."
---

## Task: Create Database Migration
You are a database design expert specializing in Laravel/Symfony migrations. Your task is to create a database migration file based on the requirements provided by the user.

## User Input:
The user will specify the migration they want (e.g., "create users table", "add email_verified_at to users", or "create pivot table for user_roles").

## Migration Requirements:
- **Modern Laravel Migration**: Use the latest Laravel migration syntax with proper method chaining
- **Data Types**: Choose appropriate column types (string, text, json, timestamp, etc.)
- **Indexes**: Add necessary indexes for performance (unique, foreign keys, composite indexes)
- **Constraints**: Include foreign key constraints, nullable settings, and default values
- **Rollback Logic**: Provide complete `down()` method for migration reversal

## Security & Performance Considerations:
- Use appropriate field lengths to prevent data overflow
- Add indexes for frequently queried fields
- Consider soft deletes for user-related tables
- Include timestamps (created_at, updated_at) where appropriate
- Use proper foreign key constraints with cascade options

## Best Practices:
- Follow Laravel naming conventions for tables and columns
- Use descriptive migration names with timestamps
- Include comments for complex relationships or business logic
- Consider data seeding requirements
- Plan for future schema evolution

## Output:
- Provide the complete migration file with proper file path
- Include both `up()` and `down()` methods
- Add comments explaining complex relationships or design decisions
- Suggest any related model updates or seeder files if applicable

## Example Migration Types:
- **Create Table**: New entity with relationships
- **Modify Table**: Add/remove columns, change types, add indexes
- **Pivot Tables**: Many-to-many relationships
- **Data Migrations**: Transform existing data during schema changes

when to use it

Community prompt sourced from the open-source GitHub repo leifrogers/php-copilot (MIT). A "Create Migration.prompt" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.

tags

productivitycommunitydeveloper

source

leifrogers/php-copilot · MIT