DEV Community

Nagarajan R
Nagarajan R

Posted on

Answer: Laravel - How to change column type (smallInteger => string)

To use the schema changing feature, you need Doctrine DBAL:

composer require doctrine/dbal

Now you can use change():

public function up()
{
    Schema::table('foo', function (Blueprint $table) {
        $table->string('driverlicensetype', 4)->nullable()->change();
    });
}

public function down()
{
    Schema::table('foo', function (Blueprint $table) {
        $table->smallInteger('driverlicensetype')->nullable()->change();
    });
}

If you prefer the raw approach…

Top comments (0)