Skip to content

MYSQL 8 Migrating text to alternative text type does not change column #46492

@liamh101

Description

@liamh101
  • Laravel Version: 10.3.3
  • PHP Version: 8.2.3
  • Database Driver & Version: MYSQL 8.0.32
  • doctrine/dbal Version: 3.6.1

Description:

The column type change will not be made during a text column's migration to medium or long text. Keeping the column as a text type.

Stepping through the process, Illuminate\Database\Schema\Grammars\ChangeColumn class line 44 $tableDiff->isEmpty() returns true.

Not sure what other columns this affects. This bug occurred during my migration process to Laravel 9 to 10.

Steps To Reproduce:

  1. Set MySQL config in database.php as follows (based on MySQL8 docker image):
        'mysql' => [
            'driver' => 'mysql',
            'url' => null,
            'host' => 'mysql',
            'port' => '3306',
            'database' => 'test',
            'username' => 'root',
            'password' => 'root',
            'unix_socket' => '',
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? [
                PDO::MYSQL_ATTR_SSL_CA => null,
                PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => 0,
            ] : [],
        ],
  1. Create a migration that creates a table with three text columns.
  2. Create another migration changing these columns:
   public function up(): void
   {
       Schema::table('tableName', static function (Blueprint $table) {
           $table->mediumText('col1')->change();
           $table->longText('col2')->change();
           $table->mediumText('col3')->change();
       });
   }
  1. Run migrations.
  2. Columns are still text type.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions