9
Views
3
Comments
Solved
Database Upgrade Error "OSUSR_SL6_XXXX"
Application Type
Mobile

Hi experts~

I'm beginner of outsystems.

I made table layout using excel for my app and imported it.

After that, I changed table Keys and field names.


I made very first app and was deploying. but it returned error like this.

"Database Upgrade Error

Could not create / change primary key in 'OSUSR_SL6_ENTITY2' table. Inconsistent database table and entity primary key definitions."


How can I fix this? I cannot find the way to detour this.

Champion
Rank: #103
Solution

Hi Ouk,

It is a common error and happens because of the change of the Primary Key in your data model. Since I've seen this error multiple times (and also the answers in various posts); let me consolidate those solutions (step by step) here.


Database Upgrade Error: Could not create / change primary key in {table-name} table. Inconsistent database table and entity primary key definitions.


OutSystems suggests to "Delete the attribute from your entity definition; or add it in the database table as specified in your eSpace".

What does it mean? How to solve it? - Here are four ways to do it.


Approach 1

  1. Go to the ServiceCenter of your environment
  2. Search for the espace
  3. Delete the espace from ServiceCenter (NOTE: Keep the module open in the service studio, while you are deleting it from ServiceCenter; this maintains the local copy, which we are going to publish in next step)
  4. Now, publish the local copy.

ALERT: You will lose the entity data (if any) and the espace version history


Approach 2

  1. Open the Service Studio
  2. Select the entity
  3. Cut and Paste the subjected entity
  4. Publish

ALERT: You will lose the entity data (if any) but the espace version history will be maintained


Approach 3 (recommended)

  1. Let the primary key attribute (say A) unchanged
  2. Create the new attribute (say B) (which you want as the new primary key; at this stage do NOT make it primary key)
  3. Publish to maintain the model and data
  4. Copy values from the existing primary key (A) to the new attribute (B)
  5. Publish to persist the data
  6. Change the attributes of A and B. Make the new column B as the new primary key
  7. Publish
  8. Delete the old attribute (A)
  9. Publish

Approach 4

  1. Open the Service Studio
  2. Select the entity (say A)
  3. Copy and Paste the subjected entity; making a duplicate (say B)
  4. Change the Primary key in the duplicated entity (B)
  5. (optional) Write code to copy the data from old (A) to new (B)
  6. (optional) publish
  7. Delete the original entity (A)
  8. Rename the new entity (B) as the old (A) to have the same name
  9. Publish

ALERT: You will lose the entity data (if any). To maintain the data, continue with the optional steps 5 and 6


Regards,

Swatantra

Champion
Rank: #103

References: Source1, Source2

Rank: #148

Hi Ouk, 

you cannot change the primary key of your table.

You need to drop that table and create it again with the correct name.

Thanks,

Manish Jawla

Champion
Rank: #103
Solution

Hi Ouk,

It is a common error and happens because of the change of the Primary Key in your data model. Since I've seen this error multiple times (and also the answers in various posts); let me consolidate those solutions (step by step) here.


Database Upgrade Error: Could not create / change primary key in {table-name} table. Inconsistent database table and entity primary key definitions.


OutSystems suggests to "Delete the attribute from your entity definition; or add it in the database table as specified in your eSpace".

What does it mean? How to solve it? - Here are four ways to do it.


Approach 1

  1. Go to the ServiceCenter of your environment
  2. Search for the espace
  3. Delete the espace from ServiceCenter (NOTE: Keep the module open in the service studio, while you are deleting it from ServiceCenter; this maintains the local copy, which we are going to publish in next step)
  4. Now, publish the local copy.

ALERT: You will lose the entity data (if any) and the espace version history


Approach 2

  1. Open the Service Studio
  2. Select the entity
  3. Cut and Paste the subjected entity
  4. Publish

ALERT: You will lose the entity data (if any) but the espace version history will be maintained


Approach 3 (recommended)

  1. Let the primary key attribute (say A) unchanged
  2. Create the new attribute (say B) (which you want as the new primary key; at this stage do NOT make it primary key)
  3. Publish to maintain the model and data
  4. Copy values from the existing primary key (A) to the new attribute (B)
  5. Publish to persist the data
  6. Change the attributes of A and B. Make the new column B as the new primary key
  7. Publish
  8. Delete the old attribute (A)
  9. Publish

Approach 4

  1. Open the Service Studio
  2. Select the entity (say A)
  3. Copy and Paste the subjected entity; making a duplicate (say B)
  4. Change the Primary key in the duplicated entity (B)
  5. (optional) Write code to copy the data from old (A) to new (B)
  6. (optional) publish
  7. Delete the original entity (A)
  8. Rename the new entity (B) as the old (A) to have the same name
  9. Publish

ALERT: You will lose the entity data (if any). To maintain the data, continue with the optional steps 5 and 6


Regards,

Swatantra

Champion
Rank: #103

References: Source1, Source2