CMDBuild Forum

Problems when deleting class

Hi all,

I am running into problems when I try to delete a class (named CentOS)
After clicking the delete button, I get

**req id** : 05e74fbde8ec498...

2020-08-17T13:39:58.584+0200

cannot delete class = "CentOS": class has cards

but when looking at the class in the data management gui, it is empty

10

I then had a look at the corresponding table in the database, and it is indeed not empty, all of my previous test cards are still in there somehow

cmdbuild=# SELECT * from "CentOS";
   Id   | IdClass  |    Code     |  Description  | Status | User  |           BeginDate           | Notes |            EndDate            | CurrentId | IdTenant |  IPMain   | Stack | Owner 
--------+----------+-------------+---------------+--------+-------+-------------------------------+-------+-------------------------------+-----------+----------+-----------+-------+-------
   5128 | "CentOS" |             | A test server | N      | rosa  | 2020-08-13 17:42:40.156255+02 |       |                               |      5128 |          | 10.1.3.45 |  4880 |      
   5303 | "CentOS" |             | Test          | N      | rosa  | 2020-08-13 17:44:09.260274+02 |       |                               |      5303 |          | 10.1.3.45 |  4880 |      
 160284 | "CentOS" |             | Test          | N      | rosa  | 2020-08-17 14:48:44.081578+02 |       |                               |    160284 |          | 10.4.1.55 |  4884 |  4193
 160903 | "CentOS" | test        | test          | N      | admin | 2020-08-17 15:00:09.733729+02 |       |                               |    160903 |          | 10.4.5.12 |  4880 |      
 161220 | "CentOS" | testserverb | tesb          | N      | admin | 2020-08-17 15:08:11.220687+02 |       |                               |    161220 |          | 10.4.1.4  |  4880 |      
   5215 | "CentOS" |             | A test server | U      | rosa  | 2020-08-13 17:40:03.927024+02 |       | 2020-08-13 17:42:40.156255+02 |      5128 |          | 10.1.3.45 |  4880 |      
   5343 | "CentOS" |             | Test          | U      | rosa  | 2020-08-13 17:43:33.310514+02 |       | 2020-08-13 17:44:09.260274+02 |      5303 |          | 10.1.3.45 |  4880 |      
 160302 | "CentOS" |             | Test          | U      | rosa  | 2020-08-17 14:48:29.360618+02 |       | 2020-08-17 14:48:44.081578+02 |    160284 |          | 10.4.1.55 |  4884 |  4193
 160952 | "CentOS" | test        | test          | U      | admin | 2020-08-17 14:59:26.417915+02 |       | 2020-08-17 15:00:09.733729+02 |    160903 |          | 10.4.5.12 |  4880 |      
 161319 | "CentOS" | testserverb | tesb          | U      | admin | 2020-08-17 15:05:54.947512+02 |       | 2020-08-17 15:08:11.220687+02 |    161220 |          | 10.4.1.4  |  4880 |      

Am I misunderstanding something or did something happen that was not supposed to happen?
Thanks for your help!

PS: The cmdbuild version I am running is 3.2.1

CMDBuild manages the history / versioning of all the data cards and relations at each modification / cancellation (see Overview Manual Paragraph 5.5 and User Manual paragraph 6.6).
Even if you deleted the data cards you entered, the historical versions remained and this prevents you from deleting the class.
However, you can set the class status to “not active” and this way it will no longer be visible in the application.

TRUNCATE “MyTableName” CASCADE; This will delete all cards and the corresponding history table. After that, you can delete the Class within CMDBuild

But, that comes with a huge warning. Messing with the database can leave the system in an inconsistent state. It seems that you have just test data there and want to start anew. Assuming that yours is not a superclass, and you haven’t got any domain (relationships) on the class, you probably can safely issue a truncate. If that class was in the menu the reference will be wrong, the definition of the permissions will have non-existent references, etc.

Thanks for the quick response!

There is indeed a domain relation in this class (Owner) so I would rather not mess around with truncating the database. But that may be valuable information for future experiments :wink:

I can live with renaming/disabling the class. As far as I understand, the only drawback is that I can not create a new class (maybe somewhere else in the tree) that is called “CentOS”, correct?