framework: [5.7] MSSQL database - renaming column causes mssql constraint issue

  • Laravel Version: v5.7.22
  • PHP Version: v7.2.15
  • Database Driver & Version: Sqlsrv (Unknown Version)

Description:

When trying to rename a column in a laravel migration, sqlsrv throws an error.

$table->renameColumn('verified', 'approved')->change();

results in:

Migrating: 2018_12_14_121213_rename_verified_to_approved_on_users_table
In Connection.php line 664:
                                                                               
  SQLSTATE[42000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]'DF_  
  1483A5E9_F45FF19' is not a constraint. (SQL: ALTER TABLE users DROP CONSTRA  
  INT DF_1483A5E9_F45FF19)  

In PDOStatement.php line 119:
                                                                               
  SQLSTATE[42000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]'DF_  
  1483A5E9_F45FF19' is not a constraint.                                       
                                                                               
In PDOStatement.php line 117:
                                                                               
  SQLSTATE[42000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]'DF_  
  1483A5E9_F45FF19' is not a constraint.   

Steps To Reproduce:

  • Create a migration to create a database/column in an mssql database.
  • Create a migration to rename the column.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 18 (18 by maintainers)

Most upvoted comments

Hm, based on your comment it would seem that it is indeed a Laravel issue (not bug)? If Laravel is using its own CREATE TABLE syntax, and not doctrine/dbal’s then surely the fix here is to use the syntax provided by doctrine/dbal?

Or alternatively use Laravel syntax throughout the entire connection and not just a mixture of Laravel and doctrine/dbal?

The workaround (at the moment) for this project is to remove this migration and do it manually which defaults the purpose of migrations. Is there perhaps a way to force Laravel to use doctrine/dbal, or have Laravel use its own syntax?