Download the PHP package mylesduncanking/laravel-simple-migration without Composer
On this page you can find all versions of the php package mylesduncanking/laravel-simple-migration. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mylesduncanking/laravel-simple-migration
More information about mylesduncanking/laravel-simple-migration
Files in mylesduncanking/laravel-simple-migration
Package laravel-simple-migration
Short Description Streamlined class for simple migrations within Laravel
License MIT
Homepage https://github.com/mylesduncanking
Informations about the package laravel-simple-migration
Laravel Simple Migration
📦 Installation
❓ Why Use This Package?
Laravel's migrations are powerful but can become verbose and repetitive, especially for simple table structures or frequent seed/migrate workflows.
Laravel Simple Migration helps you:
- Write cleaner, array-based migration definitions
- Avoid boilerplate like
->after()
and->index()
- Automatically run seeders alongside migrations
- Maintain clarity and control with a minimal syntax layer
Perfect for rapid prototyping, internal tools, or any dev who loves less noise and more flow.
🚀 Getting Started
This package builds on Laravel's native migration system. If you're familiar with Laravel migrations, this will feel familiar.
To create a simple migration:
Your migration file will contain a $migration
array for defining schema changes.
Format
🔁 Auto-After Functionality
To save time when adding multiple columns, this package adds them sequentially by default. This removes the need for ->after('column')
.
To disable this:
Then set config/simplemigration.php > auto_after
to false
.
⚡ Auto-Index Functionality
By default, any column ending in _id
will automatically get an ->index()
modifier.
Customize this behavior:
Then edit the regex rules in config/simplemigration.php > auto_index
.
To exclude a specific column from auto-indexing, add noIndex
in its modifiers array.
🌱 Seeder Functionality
Table creations or updates often require seeders. This package uses Laravel's migration tracking to automatically run seeders during the up()
method.
This package assumes that seeders are stored under \Seeds
namespace and have a class name that starts with a capital letter and ends with Seeder
.
Note: Seeders only run during
up()
by default. To run seeders during rollback (down()
), usebeforeDown()
orafterDown()
and callrunSeeder($seederName)
manually.
📘 Table Naming Convention
If a table includes an id
or uuid
column, it is assumed to be a new table. Otherwise, the table is assumed to be updated.
To explicitly define the action, use:
create:table_name
update:table_name
Or adjust assumptions globally:
Example
🏷️ Column Key Format
Format keys as {type}:{column}
.
Examples:
integer:quantity
set:status
foreignId:user_id
date:dob
=> ['nullable']
✅ Supported Modifiers
You can use all default Laravel column modifiers in array format:
nullable
default:value
unique
index
after:other_column
comment:some text
noIndex
(custom)
✨ Helper Methods
beforeDown()
Hook to perform actions before the down()
method runs.
afterDown()
Hook to perform actions after the down()
method runs.
runSeeder($seeder)
Run a seeder manually.
✏️ Example Seeder Triggered in Migration
This will run RoleSeeder
when the migration is applied.
📁 Config File
To customize assumptions and toggles:
Edit config/simplemigration.php
to:
- Enable/disable auto-index or auto-after
- Add custom regex rules
- Set type assumptions for new vs update