Looking to hire Laravel developers? Try LaraJobs
This package is not available.

laravel-migration-char-type maintained by coolseven

Description
Add Char Type For Laravel Migration
Author
Last update
2020/10/15 13:40 (dev-master)
License
Downloads
107

Comments
comments powered by Disqus

Register Char Type To Doctrine Dbal library's types map , This package enables changing a column's type to char type when using laravel's migration schema

The solution is inspired by Muhammad Zamroni's article

Usage:

composer require coolseven/laravel-migration-char-type
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class ChangePrimaryKeyFromIntToCharOnUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('users',function(Blueprint $table){
            // before change : $table->bigIncrements('id');
            $table->char('id',36)->change();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('users',function(Blueprint $table){
            $table->bigIncrements('id')->change();
        });
    }
}

TODO

  • adding tests