26
Views
9
Comments
Solved
What happens in the database when an entity name is changed?
Application Type
Traditional Web
Service Studio Version
11.9.2 (Build 34232)
Platform Version
11.0.606.0

I was wondering what happens in the database when an entity name is changed in Service Studio.

I am asking this because an entity name was changed, and while the development environment points to a table with the old name in the database, apparently the test and prod environments point to a table with the new name in the databases.


Does anyone have any idea on how and/or why this happened?


Regards,


Marios

Rank: #1868
Solution

Thanks, Joao,


This is exactly what we are planning to do.

Change the Physical name, republish the application, and test that the data is written in the original table.

Do this on our test instance, and then, if this works, repeat on production instance

I Will let you know the outcome


Regards,


Marios





Rank: #66
Solution

Hi Marios,


When you change the name of the table, what is changed is the name on the metadata so the data in your physical table is kept.

This information is saved on the Entity which you can refer from System:


The Name is the name of the entity you see in Service Studio, the physical table name is the name of the table in the database.

When you create a table called Entity1, the record in the Entity table will have name Entity1 and table name (for example) OSUSR_123_Entity1. When you change it to Entity2, the record in the Entity table will be updated to name Entity2 and table name will stay the same (for example) OSUSR_123_Entity1.

When you deploy to a new environment, it's like the table is created for the first time, so the physical table name will be Entity2 in there.


That's why they can the tables can have two different tables, but that Entity table in the metamodel ensures it works the same.


Hope it helps.


Regards,
João

Rank: #1868

Joao,

Would you suggest renaming the physical table name (ossys_Entity.[Physical_Table_Name] ) in the Entity table?


Regardsm


Marios


Rank: #66

Hi Marios,


I would not recommend updating a system table like the OSSYS_Entity is. Theoretically, if you update it would work but these tables are managed by the OutSystems plaftorm and I would not tamper with those as the platform may update this record again and your changes will be overriden.

In any case, why do you need to have the same table name? From a metamodel perspective, it works the same in Service Studio when you query {<Entity name>} in every environment.


Regards,
João

Rank: #1868

Because I need to keep the data that are in the original table, with their IDs intact.

So I can't just drop the new table, recreate it, and import the data from the original table. The IDs will change - there have been physical deletions in the original table.


  Regards, 


Marios

Rank: #66
Solution

Hi Marios,


If you have access to the database you can go ahead and rename the Physical table name.

I'd say to test it by publishing the eSpace in which the table is, to make sure the platform does not change back the Physical Table name.


João

Rank: #1868
Solution

Thanks, Joao,


This is exactly what we are planning to do.

Change the Physical name, republish the application, and test that the data is written in the original table.

Do this on our test instance, and then, if this works, repeat on production instance

I Will let you know the outcome


Regards,


Marios





Rank: #66
Solution

Hi Marios,


If you have access to the database you can go ahead and rename the Physical table name.

I'd say to test it by publishing the eSpace in which the table is, to make sure the platform does not change back the Physical Table name.


João

Hi Marios,

Basically, when we rename any entity then the physical name of that entity do not change (used by outsystem in background to execute at runtime) only the aliasing changes.

Please refer below image :

Here i have created the entity named "Book"  which has a physical_table_name of its own.


and when the name is changed to "Book_New" then 'physical_table_name' doesn't gets updated, only "Name" changes.



Hope this helps you !!


Regards,

LK

Rank: #66
Solution

Hi Marios,


When you change the name of the table, what is changed is the name on the metadata so the data in your physical table is kept.

This information is saved on the Entity which you can refer from System:


The Name is the name of the entity you see in Service Studio, the physical table name is the name of the table in the database.

When you create a table called Entity1, the record in the Entity table will have name Entity1 and table name (for example) OSUSR_123_Entity1. When you change it to Entity2, the record in the Entity table will be updated to name Entity2 and table name will stay the same (for example) OSUSR_123_Entity1.

When you deploy to a new environment, it's like the table is created for the first time, so the physical table name will be Entity2 in there.


That's why they can the tables can have two different tables, but that Entity table in the metamodel ensures it works the same.


Hope it helps.


Regards,
João

Rank: #1868

Joao,

Would you suggest renaming the physical table name (ossys_Entity.[Physical_Table_Name] ) in the Entity table?


Regardsm


Marios


Rank: #66

Hi Marios,


I would not recommend updating a system table like the OSSYS_Entity is. Theoretically, if you update it would work but these tables are managed by the OutSystems plaftorm and I would not tamper with those as the platform may update this record again and your changes will be overriden.

In any case, why do you need to have the same table name? From a metamodel perspective, it works the same in Service Studio when you query {<Entity name>} in every environment.


Regards,
João

Rank: #1868

Because I need to keep the data that are in the original table, with their IDs intact.

So I can't just drop the new table, recreate it, and import the data from the original table. The IDs will change - there have been physical deletions in the original table.


  Regards, 


Marios

Rank: #66
Solution

Hi Marios,


If you have access to the database you can go ahead and rename the Physical table name.

I'd say to test it by publishing the eSpace in which the table is, to make sure the platform does not change back the Physical Table name.


João

Rank: #1868
Solution

Thanks, Joao,


This is exactly what we are planning to do.

Change the Physical name, republish the application, and test that the data is written in the original table.

Do this on our test instance, and then, if this works, repeat on production instance

I Will let you know the outcome


Regards,


Marios





Rank: #256

When you change the name of an entity in Service Studio, it is just the logical name that changes. The physical table name will remain the same once the table has been created. 

However, if you push your application to a test or production environment after the name change, (so the table didn't exist there yet), it will get a physical table name based on the new name of the entity. So you have to be very careful, as the physical table names of an entity are very frequently different on each environment.

If you want to see the link between the logical and physical table names, check the ossys_entity table.

(right, I should either type faster, or not get distracted by phone calls or emails when answering questions here)

Rank: #1868

Good morning guys,


Thanks for the answers.

I need to add here that this case had a simple peculiarity: I created a new database catalog and moved the entity (amongst others) to the new catalog. In all three environments, DEV, TEST, and PROD. And while in the DEV environment, the entity points to the old table name, in the TEST and PROD environments, the entity point to the new table name.

How can this be?


Regards,


Marios