Looking to hire Laravel developers? Try LaraJobs

laravel-migration maintained by hughcube

Description
The Laravel Migration package.
Author
Last update
2020/03/26 03:11 (dev-master)
License
Links
Downloads
28

Comments
comments powered by Disqus

Installing

$ composer require hughcube/laravel-migration -vvv

Basic Usage (In artisan file)

#!/usr/bin/env php
<?php

use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;

/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| First we need to get an application instance. This creates an instance
| of the application / container and bootstraps the application so it
| is ready to receive HTTP / Console requests from the environment.
|
*/
$app = require __DIR__ . '/bootstrap/app.php';

/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/
$kernel = $app->make(
    'Illuminate\Contracts\Console\Kernel'
);

/** !!! Register after kernel is created  */
$app->register(\HughCube\Laravel\Migrations\ServiceProvider::class);

exit($kernel->handle(new ArgvInput, new ConsoleOutput));

Example

<?php

use Illuminate\Database\Migrations\Migration;
use HughCube\Laravel\Migrations\Blueprint;
use HughCube\Laravel\Migrations\Schema;

class CreateExampleTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('example', function (Blueprint $table) {
            $table->id();
            $table->timestamps();
            
            /** Set table comment */
            $table->comment = "Example";
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('example');
    }
}