migrations: Unable to change the version column length into the table migration_version

BC Break Report

I have upgraded the doctrine migration from the version 1.8.1 to 2.0.0 but when I want check the status of the database migration an exception is throwed.

Q A
BC Break yes
Version 2.0.0

Summary

This query is tried to run: ALTER TABLE migration_versions ALTER COLUMN version NVARCHAR(14) NOT NULL

Previous behavior

No error displayed !

Current behavior

The result is this error:

In PDOConnection.php line 90:

  [Doctrine\DBAL\Driver\PDOException (42000)]
  SQLSTATE[42000]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]The objet 'PK__migratio__79B5C94C0C85DE4D' depends to column 'version'.

Unable to use the doctrine migration.

How to reproduce

My version column has 510 in length

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 18 (7 by maintainers)

Most upvoted comments

FWiW, I’ve just come across this problem in SQL Server 2017 when migrating to 2 from 1.8

$ php bin/migrations.php --db-configuration=migrations-windev-online-dev.php -n status

In DBALException.php line 169:

  An exception occurred while executing 'ALTER TABLE migration_versions ALTER COLUMN version NVARCHAR(14) NOT NULL':

  SQLSTATE[42000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The object 'PK__migratio__79B5C94C0E391C95' is dependent on column 'version'.


In PDOConnection.php line 80:

  SQLSTATE[42000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The object 'PK__migratio__79B5C94C0E391C95' is dependent on column 'version'.


In PDOConnection.php line 75:

  SQLSTATE[42000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The object 'PK__migratio__79B5C94C0E391C95' is dependent on column 'version'.


status [--show-versions] [--configuration [CONFIGURATION]] [--db-configuration [DB-CONFIGURATION]]```

Same issue here, after upgrading to doctrine/doctrine-migrations-bundle v2.0.0 and doctrine/migrations v2.0.0

An exception occurred while executing
'ALTER TABLE migration_version ALTER COLUMN   
  version NVARCHAR(14) NOT NULL':

SQLSTATE [42000, 5074]: [Microsoft][ODBC  
   Driver 17 for SQL Server][SQL Server]The object 'PK__migratio__79B5C94CB7E  
  C3F78' is dependent on column 'version'.

SQLSTATE [42000, 4922]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]ALTER TABLE ALTER COLUMN version failed because one or more objects access this column.

We’re running SQL Server 2016, which requires you to drop all indexes on a column before changing its length.

migrations bundle config:

doctrine_migrations:
    dir_name: '%kernel.project_dir%/src/Migrations'
    namespace: DoctrineMigrations
    table_name: migration_version

CREATE TABLE definition (pre-2.0.0):

CREATE TABLE migration_version (
  version NVARCHAR(255) NOT NULL
    PRIMARY KEY
)

Explicitly configuring column_length: 255 solved the issue for us, for now.