Laravel Migration & Model Generator
Generate Laravel migrations and Eloquent models from a simple column definition. Save time scaffolding database tables.
Plural and snake_case. The model is derived automatically (posts → Post).
One column per line with format: name:type:modifiers. Examples below.
Types: id, string, string(100), text, integer, bigint, boolean, float, float(8,2), decimal(8,2), date, datetime, timestamp, json, uuid, foreignId, timestamps, softDeletes, rememberToken. Modifiers: nullable, unique, index, unsigned, default(value), constrained, onDelete(cascade), comment(text).
Generated code
Migration and Eloquent model
What is a Laravel migration generator?
Migrations are Laravel's way of defining and versioning your database schema in PHP code. This generator converts a simple column definition (name, type, modifiers) into a complete migration ready to run with php artisan migrate, plus the matching Eloquent model with fillable and casts already configured. It saves the repetitive work of writing the syntax by hand for every new table.
How to use this tool
- Write the table name in plural and snake_case.
- Define each column on its own line with the name:type:modifiers format.
- Review the generated migration and model and copy the code.
- Paste the migration into database/migrations with the correct date suffix and run php artisan migrate.
Database tips
- Use foreignId(...)->constrained() for foreign keys: Laravel infers the referenced table and column automatically.
- Define casts in the model so Eloquent converts booleans, dates and JSON automatically.
- Add ->onDelete('cascade') when deleting the parent must delete children, and ->nullable() on optional columns.
Frequently asked questions
How is the migration file named?
With php artisan make:migration create_posts_table it is generated automatically with the date. If you create the file manually, the name must be YYYY_MM_DD_HHMMSS_create_posts_table.php.
What does the down() method do?
It defines the migration rollback (usually dropIfExists). It runs with php artisan migrate:rollback to undo changes.