Skip to content

SQL Server: ALTER TABLE foo ALTER COLUMN bar NVARCHAR(36) NOT NULL throws "The index 'idx_foo' is dependent on column 'foo'" #6913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
savemetenminutes opened this issue Apr 16, 2025 · 0 comments

Comments

@savemetenminutes
Copy link

savemetenminutes commented Apr 16, 2025

Bug Report

Q A
Version x.y.z
Previous Version if the bug is a regression x.y.z

Summary

SQL Server

It seems that trying to change a column
E.g.

$table->getColumn('foo')->setNotnull(true);

on a column that is referenced in an index results in an error. I would assume this is also true for any constraints associated with the column as well.

Current behavior

  [Doctrine\DBAL\Exception\DriverException]
  An exception occurred while executing a query: SQLSTATE[42000]: [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]The index 'idx_un_sales_bm_company_category_uuid' is dependent on column 'uuid'.

Expected behavior

This can potentially be worked around by dropping all indexes and constraints, which reference the column that has to be changed and then recreating them after the ALTER TABLE ... statement has completed.

How to reproduce

To be provided...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant