skip to Main Content

I have about 30+ migration files.

When it gets to a migration which contains a column rename:

Schema::table('table', function (Blueprint $table) {
 $table->renameColumn('old_field', 'new_field');
});

It only errors once it gets to this migration (let’s say, number 15). It runs all other migrations just fine. If I comment this out, then it will complete as expected.

I run php artisan migrate or php artisan migrate:fresh

I get the following error:

 ErrorException  : The "name" column option is not supported, setting it is deprecated and will cause an error in Doctrine 3.0

  at /Volumes/Workspace/new-app-backend/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Column.php:85
    81|                 @trigger_error(sprintf(
    82|                     'The "%s" column option is not supported,' .
    83|                     ' setting it is deprecated and will cause an error in Doctrine 3.0',
    84|                     $name
  > 85|                 ), E_USER_DEPRECATED);
    86| 
    87|                 continue;
    88|             }
    89|             $this->$method($value);

  Exception trace:

  1   trigger_error("The "name" column option is not supported, setting it is deprecated and will cause an error in Doctrine 3.0")
      /Volumes/Workspace/new-app-backend/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Column.php:85

  2   DoctrineDBALSchemaColumn::setOptions()
      /Volumes/Workspace/new-app-backend/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Column.php:67

php -v gives me this:

PHP 7.3.14 (cli) (built: Jan 24 2020 03:04:31) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.14, Copyright (c) 1998-2018 Zend Technologies
    with Xdebug v2.9.2, Copyright (c) 2002-2020, by Derick Rethans
    with Zend OPcache v7.3.14, Copyright (c) 1999-2018, by Zend Technologies

Mysql -v gives me this:

Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 323
Server version: 5.7.29 Homebrew

I am using “doctrine/dbal”: “~2.3”

This error only happens when running migrate on my local machine. On my docker-compose stack and within a Vagrant box is completes as expected. All versions are the same across the board. Why would this be happening only on my mac?

2

Answers


  1. It seems to be solved in v2.7 [bug] Don’t skip column options. #3089.

    2.7 breaks renaming columns in mysql 5.7 #3091

    Upgrade the package version using composer update doctrine/dbal.

    Login or Signup to reply.
  2. Workaround i found it across the internet

    Schema::table('table', function (Blueprint $table) {
        DB::statement("ALTER TABLE table_name
    CHANGE COLUMN old_column_name new_column_name data_type;");
    });
    

    I hope this helps.

    References

    1. Failed to rename a column in a migration
    2. Rename a column in MySQL
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search