Renaming a column in an Entity creates new column but does not copy data

Renaming a column in an Entity creates new column but does not copy data

  

We are using platform and service studio versions 10.0.405.0 with SQL database in the PaaS cloud environment.

When renaming a column on an entity, a new column is created when publishing, but no existing data is copied across to the new column. 

We renamed a column with a unique index but could not publish because the data in the new column is not unique, obviously because no data was copied across.

Our workaround:

  1. Remove the unique index and publish the change
  2. Copy the data to the new column by running an update script
  3. Re-enable the unique index and publish

The issue only presented on DEV as we had no data in TEST or PROD yet.

Questions:

  1. Is this expected behavior?
  2. Why not simply rename the column in SQL?


Regards
Hanno

Solution

Hi Hanno,

Yes, that's the expected behavior. Renaming the column on SQL could compromise the ability to rollback the version afterwards.

For example, consider an entity with an attribute called Name:

  1. Publish first version (v1)
  2. Add some records to the entity
  3. Change the attribute Name to FullName and publish (v2)
  4. Create a new attribute called Name and publish (v3)
  5. Rollback to v1

With the current behavior, step 4 will essentially reuse the column that already exists, so step 5 is straightforward.

If the column was actually renamed, step 5 would be unable to rename the column since it already exists.

Regards,

Paulo Ferreira

Solution

Thank you for clarifying that Paulo