directus icon indicating copy to clipboard operation
directus copied to clipboard

Can't update a field that has a unique index

Open rijkvanzanten opened this issue 4 years ago • 3 comments

MS SQL doesn't allow altering a column that has an active unique index. I'm not sure if we should work around it in Directus itself somehow, or if this can be abstracted away in knex (ref @nickrum). Lets see how https://github.com/knex/knex/issues/4390 pans out

rijkvanzanten avatar Mar 23 '21 22:03 rijkvanzanten

Should be doable 😁 I think Knex is already doing something similar for default constraints, so there is no real reason to not do the abstraction for unique indices within Knex as well.

nickrum avatar Apr 09 '21 10:04 nickrum

The unique index itself can't be deleted through Directus, apparently since the drop index command is followed by an alter column command. Whenever the only change is removing the unique index, the latter is redundant, right?

paulboudewijn avatar Nov 12 '21 11:11 paulboudewijn

This is still an issue. The only way to remove a field set as "Unique" is to delete the index directly from the database.

pmorin17 avatar Apr 29 '24 19:04 pmorin17