Skip to content

make:migration ​

Create a database migration file

Signature: modularous:make:migration

Alias: mod:m:migration

Category: Make


Description ​

Generates a timestamped migration file for a module or the host app. Supports all standard Laravel migration patterns (create, add, delete, drop, plain) plus two Modularous-specific pivot patterns. When --addTranslation or --addSlug traits are active, companion translation/slug migration blocks are appended automatically.


Usage ​

modularous:make:migration [options] <name> [<module>]

Arguments ​

ArgumentRequiredDescription
nameyesMigration name (e.g. create_posts_table, add_status_to_posts_table)
modulenoTarget module; omit for database/migrations/

Options ​

OptionShortDescription
--fields=Schema field string (title:string,body:text)
--route=Route name used for pivot table naming
--relational=Pivot type: BelongsToMany or MorphedByMany
--table-name=Override auto-derived table name
--plainCreate an empty migration body
--selfWrite to Modularous vendor migrations
--force-fOverwrite existing files
--no-defaultsSkip Modularous default fields
--testDry-run / preview mode

Trait flags (affect extra schema blocks) ​

-T / --addTranslation, -S / --addSlug


Examples ​

Create table migration ​

bash
php artisan modularous:make:migration create_posts_table Blog \
    --fields="title:string,body:text,published_at:timestamp:nullable"

Add column to existing table ​

bash
php artisan modularous:make:migration add_status_to_posts_table Blog \
    --fields="status:string"

Pivot table (BelongsToMany) ​

bash
php artisan modularous:make:migration create_blog_post_tag_table Blog \
    --relational=BelongsToMany \
    --route=post \
    --fields="tag_id:unsignedBigInteger"

Morph pivot table ​

bash
php artisan modularous:make:migration create_taggables_table Blog \
    --relational=MorphedByMany

Migration with translation table ​

bash
php artisan modularous:make:migration create_posts_table Blog \
    --fields="title:string,body:text" \
    --addTranslation

Plain migration (empty up/down) ​

bash
php artisan modularous:make:migration add_indexes_to_posts_table Blog --plain

Migration naming conventions ​

Name patternMigration type
create_*_tableSchema::create()
add_*_to_*_table$table->addColumn()
delete_*_from_*_table$table->dropColumn()
drop_*_tableSchema::drop()
anything elseplain

See also ​