180
Views
2
Comments
Solved
How to drop a primary key? 
Question

I need to drop a primary key because it is a data type of text. After the key is dropped, I need to create a key for the entity that is not of type text. 


my question: how can I drop a key from an entity? 

mvp_badge
MVP
Solution

Hello Michael,

As far as I know, it is not possible to drop or change a primary key.
In the past I tried the approach described here, by J., and also a few different approaches, but all the time the compiler complained about inconsistence between the primary key definition and the table definition.

So, the easiest way, if you do not have data to worry about, is just copy/paste the entity, change the Primary Key data type, delete the old entity, rename the new entity to have the same name as the old one (optional) and publish the module. A new table in the database will be created with the new structure.

If you have data, just do the same, without deleting the old entity, and do code to copy data from one entity to the other, and than later on replace the old entity by the new one.

Cheers.

mvp_badge
MVP

Hi,

You can change identifier by just right click on that column.

or double click on entity and see more option.



Thanks,

Jitendra

mvp_badge
MVP
Solution

Hello Michael,

As far as I know, it is not possible to drop or change a primary key.
In the past I tried the approach described here, by J., and also a few different approaches, but all the time the compiler complained about inconsistence between the primary key definition and the table definition.

So, the easiest way, if you do not have data to worry about, is just copy/paste the entity, change the Primary Key data type, delete the old entity, rename the new entity to have the same name as the old one (optional) and publish the module. A new table in the database will be created with the new structure.

If you have data, just do the same, without deleting the old entity, and do code to copy data from one entity to the other, and than later on replace the old entity by the new one.

Cheers.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.