Skip to content

Enables Changing a column's type to char for laravel migrations

License

Notifications You must be signed in to change notification settings

coolseven/laravel-migration-char-type

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Enables Changing a column's type to char for laravel migrations

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages