marlek / laravel-automigrate by marlek

Laravel package which allows automatically running migrations from different folders, useful when you have custom folder structure
2,550
14
3
Package Data
Maintainer Username: marlek
Maintainer Contact: markotheman@gmail.com (Marko Lekić)
Package Create Date: 2014-03-08
Package Last Update: 2016-10-11
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-04-18 15:00:07
Package Statistics
Total Downloads: 2,550
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 14
Total Watchers: 3
Total Forks: 0
Total Open Issues: 0

Laravel Automigrate

Build Status

Laravel package which allows automatically running migrations from different folders, useful when you have custom folder structure

NOTE: This package is not necessary with Laravel/Lumen version 5.3 and above, as it supports custom directories for migrations. 
Look up loadMigrationsFrom() function in the documentation.

Installing

Require the package with composer:

composer require marlek/laravel-automigrate

When the installation completes, open your app/config/app.php file and add this item to the array of providers:

'Marlek\LaravelAutomigrate\LaravelAutomigrateServiceProvider'

Finally you can run artisan command in the root of you application and see automigrate in the list of artisan commands

php artisan

Using in Laravel

You need to define the list of migrations you want to run in the configuration of the package. To do this, you first need to publish the configuration:

php artisan vendor:publish

Then you need to open app/config/laravel-automigrate.php file and pass paths array like this:

<?php
    return [
        'paths' => [
            'path/to/migrations_folder_one',
            'path/to/migrations_folder_two'
        ]
    ];

Finally, the only thing left to do is run the command to migrate your database

php artisan automigrate

Using in Lumen

Since Lumen doesn't have vendor:publish command, you'll need to add package configuration yourself.

I recommend adding it in bootstrap/app.php like this:

config(
    [
        'laravel-automigrate.paths' => [
            'path/to/migrations_folder_one',
            'path/to/migrations_folder_two'
        ]
    ]
);

After this, just like in Laravel, you need to run the command to migrate your database

php artisan automigrate

Reset previous migrations

If you want to reset previous migrations before running migrate again, just pass the reset option

php artisan automigrate --reset

Seed the database

Just like migrate command, this command accepts seed option, in case you want to seed your database after the migrations

php artisan automigrate --seed

Reset and seed can be combined into a command which will reset your migrations, run all migrations again and after that seed the database

php artisan automigrate --seed --reset

Regular migrate command will be run after all package migrations

Older versions of Laravel

If you're using Laravel 4.* you should use the package version 1.2:

composer require marlek/laravel-automigrate:1.2