288
Views
5
Comments
Solved
DB Cleanup

Hi Team,

I want to cleanup the database space for our environment. We tried using the option from Service Center to older versions, it shows up some versions which we do not want to delete. Do we have any screen from where we can select the module versions which we are good to discard?

We tried making use of DB Cleaner - we cannot delete particular module versions, we can delete based on the date range. On checking found the DB cleaner only gives the count of how many versions are getting deleted. How can we authenticate whether that were the only modules in that range?

To meet this, we implemented a customized logic to delete the older versions. Entities we are considering are - Espace Version, Publishing.

While trying to delete from our logic we get the below error, can anyone help us how we can achieve this?

The DELETE statement conflicted with the REFERENCE constraint "OSFRK_OSSYS_ESPACE_OSSYS_ESPACE_VERSION_VERSION_ID". The conflict occurred in database "OSDEV1", table "dbo.ossys_Espace", column 'VERSION_ID'.
The statement has been terminated.


Along with this, do we need to clear the logs to free up the space? Is it a good approach to make use of schedulers available in DB Cleaner to cleanup the logs.

We appreciate the guidance provided in advance!

Thanks,

Neha Agrawal

2018-10-29 08-31-03
João Marques
 
MVP
Solution

Hi Newa,


What the error message says, is that you cannot delete a record in the Espace entity, while there is at least one record with a foreign key pointing to that record in the Espace_Version entity.

In other words, you need to clean all the versions for an Espace, before removing the eSpace.


In any case, take into account that you are "playing" with internal metadata tables and it's something you should avoid. I would suggest using DB Cleaner on Steroids component, which is an improved version of DB Cleaner.


Kind Regards,
João

2023-12-11 08-54-13
Neha Agrawal
Champion

Correct.

We are deleting the records from espace versions and not the record for espace.

2018-10-29 08-31-03
João Marques
 
MVP

Then, it's the other way around.

You're trying to remove an espace version for which there is an Espace referring it (foreign key).

The {Entity} table has a foreign key in the attribute Version_Id. That's why you have an error:


Kind Regards,
João

2023-12-11 08-54-13
Neha Agrawal
Champion

Yeah..

Seems that there are multiple entities storing this information with many-to-many cardinalities.

Will check if we can achieve this using the already available forge tools suggested above.

Thank You, appreciate it.

Regards,

Neha Agrawal

2022-12-01 15-49-00
Marcus Funke

Hello Neha,


You cannot delete a record in the "Espace" entity, as long as there is at least one record with a foreign key pointing to that record in the "Espace_Version" entity.


As mentioned above, you need to clear all versions of an "Espace_Version", before removing the "Espace".


Or you can also, in the "Espace_Version" entity, modify the "Delete Rule" in the "Foreing Key" that references the "Espace" entity.


More information in the content:

Delete Rules - OutSystems 11 Documentation 

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