Looking to hire Laravel developers? Try LaraJobs

laravel-mysql-move-column maintained by daniel-de-wit

Description
A Laravel package for simplifying rearranging MySQL database columns
Author
Last update
2025/03/31 14:07 (dev-main)
License
Downloads
147
Tags

Comments
comments powered by Disqus

Laravel MySQL Move Column

Software License Tests Coverage Status Latest Version on Packagist Total Downloads

A Laravel package for simplifying rearranging MySQL database columns.

Installation

You can install the package via composer:

composer require daniel-de-wit/laravel-mysql-move-column

The package is loaded using Package Discovery, when disabled read Manual Installation.

Usage

The method moveColumn is made available for moving a MySQl column to a new position.

<?php

declare(strict_types=1);

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('users', function (Blueprint $table): void {
            $table->moveColumn('name', 'id');
        });
    }
};

Manual Installation

When disabled, register the LaravelMySQLMoveColumnServiceProvider manually by adding it to your config/app.php

/*
 * Package Service Providers...
 */
 DanielDeWit\LaravelMySQLMoveColumnServiceProvider\Providers\LaravelMySQLMoveColumnServiceProvider::class,

Testing

composer test

Credits

License

The MIT License (MIT). Please see License File for more information.