V8-archive: Cannot delete primary key

Created on 28 Sep 2018  Â·  6Comments  Â·  Source: directus/v8-archive

The API allows you to create field with a primary key, but there's not way to delete the primary key. To delete a constraint in MySQL, it requires the name of the constraint.

bug wontfix api

Most helpful comment

To be honest, I don't really see this as a critical bug right now. Every collection needs a PK and won't function without one. We can't rename fields since the column name is referenced throughout settings/relationships.

We are currently beholden to ZendDB, which doesn't support this and isn't really getting many updates these days. So we don't have a lot of options.

We're not at a point where Directus is a full database admin tool yet, so I think we'll just need to live with this. If we port the API to Node this issue should go away. I'll downgrade this to High priority for now... and will add the wont fix tag until someone has a proper solution.

All 6 comments

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@WellingGuzman — what do we need to add/track so that we know the constraint and can delete it?

We need to find the name of the key in INFORMATION_SCHEMA database (on MySQL).

This is a start, but we need to make sure the key is not a compound key before dropping it.

Also dropping constraint doesn't work for MySQL on Zend DB. Read here: https://github.com/zendframework/zend-db/issues/36

So we get the constraint name, make sure it's not a compound key... but can we still delete it if there's that Zend issue?

@WellingGuzman

Dropping constraint doesn't work on Zend DB. I am not aware if there's a workaround. If we want to support we either create a workaround in Zend DB or Directus itself.

To be honest, I don't really see this as a critical bug right now. Every collection needs a PK and won't function without one. We can't rename fields since the column name is referenced throughout settings/relationships.

We are currently beholden to ZendDB, which doesn't support this and isn't really getting many updates these days. So we don't have a lot of options.

We're not at a point where Directus is a full database admin tool yet, so I think we'll just need to live with this. If we port the API to Node this issue should go away. I'll downgrade this to High priority for now... and will add the wont fix tag until someone has a proper solution.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cdwmhcc picture cdwmhcc  Â·  3Comments

rijkvanzanten picture rijkvanzanten  Â·  3Comments

vuhrmeister picture vuhrmeister  Â·  3Comments

gitlabisbetterthangithub picture gitlabisbetterthangithub  Â·  3Comments

metalmarco picture metalmarco  Â·  3Comments