coolseven/laravel-migration-char-type

Add Char Type For Laravel Migration

V2.0.0 2020-10-15 11:40 UTC

This package is auto-updated.

Last update: 2024-05-15 20:06:40 UTC


README

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