Currently i'm doing an install of CMDBuild, but to say the least, the interface of creating classes, attributes, domains and such, is a bit cumbersome. So i devised a method to speed development up, especially since i'm currently in the process of revising my database schema quite a lot :)
So i'm working on the following:
Create an excelsheet with 3 tabs: classes, domains, lookups
From this excelsheet i will create a YAML file which i plan to using in ansible to create all classes. (since i'm using ansible this is the most logical solution for me, however every yaml template engine could take the yaml + template and create the SQL )
So far i have concluded the following workflow to create a useable database from the cmdbuild_dd_sql.log file
- create lookuptype: INSERT INTO "LookUp" ("Status", "Type", "Number", "IsDefault", "User") VALUES ('A','$lookup','1','false','system');
- create lookupvalue using INSERT INTO "LookUp" ("Notes", "Status", "Description", "Type", "Number", "IsDefault", "Code", "User") VALUES ('$notes','A','$Description','$Lookup','$incrementalvalue','false','$code','system');
- create class: SELECT * FROM cm_create_class('$classname', '$parent', 'DESCR: $classname|MODE: write|STATUS: active|SUPERCLASS: $superclass?|TYPE: class|USERSTOPPABLE: false');
- create domain: SELECT * FROM cm_create_domain('$domainname', 'LABEL: $label|DESCRDIR: $description|DESCRINV: $inverse|MODE: write|STATUS: active|TYPE: domain|CLASS1: $classleft|CLASS2: $classright|CARDIN: $cardinality|MASTERDETAIL: $masterdetail|MDLABEL: $detaildescr');
- create attributes: SELECT * FROM cm_create_attribute('"$class"'::regclass,'$attrname','$attrtype',null,false,false,'STATUS: active|BASEDSP: true|CLASSORDER: 0|DESCR: $description|GROUP: |INDEX: $incremental|MODE: write|FIELDMODE: write');
and so on.
However, is there any documentation out there which describe these functions? It's pretty hard work digging through the logfile searching for all types of queries and which values go where :) Especially the last text variable (comment) in the function.Also, am i on the right track?
Final result will be an SQL file to create the database schema without dumping existing database schema's. Not to mention when you create a database and notice a small error in the classname, for example administators instead of administrators. Currently the only solution is to delete the class and re-create the class. I know all of you probably did this dozens of times ;)
I hope this is a good step into the right directory for schema import
s
(oh and finally where has the default attribute value gone to? in older versions there was an option to insert a default value for an attribute, but it's gone in the current version)