Skip to content
PromptPilot AI

Library / Coding & Technology / Database

Laravel: add a safe database migration

New column/table with indexes, rollback and model updates.

Cursor / coding agentsClaude CodeChatGPTClaudelaravel
Who it's for
Developers using AI coding tools
Use case
Database
Output
Agent task · Free
Prevents: Edits an existing migration, forgets indexes, or breaks rollback.
Add a migration to [describe change, e.g. add a nullable "gst_number" to customers].

Requirements:
- Create a NEW migration with php artisan make:migration; never edit existing migrations.
- Provide a working down() method.
- Add indexes for foreign keys and columns used in where/order clauses.
- For large tables, avoid changes that lock the table for long; tell me if that's a risk.
- Update the model ($fillable, casts, relationships) and the factory.
- Add or update a feature test that uses the new column.
Run php artisan migrate and php artisan test, and show the output.

Copies your prompt and opens the official site in a new tab. You may need to paste it yourself (Ctrl/⌘ + V). Nothing is sent to the AI by us.

Replace [bracketed] parts with your own details before sending. Want it tailored? Build a custom website & app development prompt.

Before vs after

A typical one-line request compared with this prompt. We only show sample responses where we've written an illustration.

BeforeWhat people usually type

Prompt

database

1 words · no role, context, format or constraints

AfterThis library prompt

Prompt

Add a migration to [describe change, e.g. add a nullable "gst_number" to customers].

Requirements:
- Create a NEW migration with php artisan make:migration; never edit existing migrations.
- Provide a working down() method.
- Add indexes for foreign keys and columns used in where/order clauses.
- For large tables, avoid changes that lock the table for long; tell me if that's a risk.
- Update the model ($fillable, casts, relationships) and the factory.
- Add or update a feature test that uses the new column.
Run php artisan migrate and php artisan test, and show the output.

97 words · generated instantly from templates, no AI called

What we added

  • Your details: [brackets] for the facts only you know
  • Output format with tables: structure of the answer

Related prompts