12
Views
6
Comments
Database upgrade Error.

Hello ,


Database Upgrade Error


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



When I'm converting from default Id  to EmployeeId which is Referential Entity in EmployeePicture Entity...then Showing this type of  "   'OSUSR_BU1_EMPLOYEEPICTURE1' table  " Error.


how to fix this Error...



Screenshot (1).png
Screenshot (2).png
2026-06-20 17-43-43
Sherif El-Habibi
Champion

Hi @Rajkamal Singh Jhala,

Try cut and paste EmployeePicture entity, change the id to EmployeeId and try to publish again.

2016-04-22 00-29-45
Nuno Reis
 
MVP

Just a warning that this will lose all data on the new table.

If it is important to keep, better copy+paste; migrate the data from old to new table with a timer, and then delete the old table.

2026-06-20 17-43-43
Sherif El-Habibi
Champion

Exactly, It might not be the best approach and adding it will also leave another copy of the Table in Outsystems database which can be dropped using something like db cleaner

UserImage.jpg
Rajkamal Singh Jhala

Thanks a lot 😊 

2026-06-20 17-43-43
Sherif El-Habibi
Champion
2023-12-26 10-35-28
OutSystems Neo
Staff
AI Generated

Changing the primary key of an entity in OutSystems requires careful consideration, as it can lead to database inconsistency. In your case, the error indicates an inconsistency between the new primary key (EmployeeId) in your OutSystems application and the existing schema in the database. Since primary keys are fundamental to data integrity, changes to them must be carefully managed.

Here are some approaches which you can follow to resolve the issue:

  • Keep the current primary key (Id) intact and create a new attribute called EmployeeId.
  • Publish your module (this ensures the database structure matches the current model).
  • Migrate the data:
    • Copy existing values from the Id column into the new EmployeeId column.
  • Change the EmployeeId to the primary key (you’ll likely need to make the current Id attribute a plain attribute first).
  • Publish your module again.
  • Verify that everything is working correctly, then you may delete the previous Id attribute if not needed anymore. Database Upgrade Error "OSUSR_SL6_XXXX"

2. Duplicate the Entity

  • Make a copy of your current entity (e.g., call it EmployeePictureBackup).
  • Specify EmployeeId as the primary key for the new entity.
  • Implement logic to copy data from the current OSUSR_BU1_EMPLOYEEPICTURE1 table to the new entity.
  • Update your application logic to reference the new entity.
  • Once confirmed that everything works, delete the original entity and, optionally, rename the new entity back to OSUSR_BU1_EMPLOYEEPICTURE1. Database Upgrade Error "OSUSR_SL6_XXXX"

3. Delete the Attribute and Let OutSystems Recreate It

  • Delete the EmployeeId attribute from the entity.
  • Publish the module to remove that column from the database.
  • Then re-add EmployeeId and specify it as the primary key.
  • Publish the module again.
  • Note: This approach will result in loss of data if no backup is taken. Database Upgrade Error "OSUSR_SL6_XXXX"

4. Delete and Republish the Module (Data Loss Warning)

  • Go to Service Center.
  • Locate the eSpace for your module, ensure it is open in the Service Studio.
  • Delete the module from Service Center.
  • Publish the open module again from Service Studio.
  • Warning: Data and version history will be lost. Database Upgrade Error "OSUSR_SL6_XXXX"

5. Manually Handle Database Changes (If Database Access is Available)

  • If you have direct access to the database, you can manually align the database with the changes in your module:
    • Change the column type and/or primary key directly via SQL.
  • However, manually modifying the database should be approached with caution and is generally recommended only for advanced users. Database Upgrade Error Column 'OSUSR_TUD_CONTRACT1.CONTRACTFILENAME' exists

Additional Notes

  • Changing primary keys or column types in OutSystems should be done sparingly and with planning, as it can disrupt database integrity.
  • Always backup your data before proceeding with any of these steps to prevent data loss.

These approaches should help resolve your issue. Option 1 is typically the most user-friendly as it minimizes data loss and application interruptions.

This answer was AI-generated. Please read it carefully and use the forums for clarifications
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.