This shows you the differences between two versions of the page.
Next revision | Previous revision Next revision Both sides next revision | ||
devel:update-database-schema [2012/09/14 12:56] miconda created |
devel:update-database-schema [2012/09/14 13:17] miconda |
||
---|---|---|---|
Line 9: | Line 9: | ||
</ | </ | ||
- | Each table is defined in the file tablename.xml. | + | Each table is defined in the file tablename.xml. |
+ | |||
+ | < | ||
+ | lib/ | ||
+ | </ | ||
Changing the database schema (adding new tables, adding/ | Changing the database schema (adding new tables, adding/ | ||
- | Regeneration of the database creation scripts is done with the command: | + | Regeneration of the database creation scripts is done running |
< | < | ||
Line 19: | Line 23: | ||
</ | </ | ||
- | This command generates the SQL or control files to be used by kamdbctl tool when creating the database structure. | + | This command generates the SQL or control files to be used by kamdbctl tool when creating the database structure. It requires the tool **xsltproc** to process the XML files, tool which is also needed for generation of the readme files. |
Changing the structure of an existing database table requires only the above steps. Adding a new table requires as well: | Changing the structure of an existing database table requires only the above steps. Adding a new table requires as well: | ||
* adding the table to be part of a specific group of tables. If the table is used by a module that uses other tables, all of them have to be in the same group. Tables group definitions are stored in the files kamailio-groupname.xml . It is common to use the module name as the group name. | * adding the table to be part of a specific group of tables. If the table is used by a module that uses other tables, all of them have to be in the same group. Tables group definitions are stored in the files kamailio-groupname.xml . It is common to use the module name as the group name. | ||
* adding the table to kamctl and kamdbctl tools for creation | * adding the table to kamctl and kamdbctl tools for creation | ||
+ | |||
+ | For example, the group of the tables used by module domain is specified in file: | ||
+ | |||
+ | < | ||
+ | lib/ | ||
+ | </ | ||
+ | |||
+ | It includes references to two tables: domain and domain_attrs. | ||
If you add a new table, you must add the new files related to it to GIT repository, before committing the changes. | If you add a new table, you must add the new files related to it to GIT repository, before committing the changes. | ||
Line 30: | Line 42: | ||
* one for the XML files (they are part of internal library srdb1) | * one for the XML files (they are part of internal library srdb1) | ||
* one for DB creation scripts (they are part of kamctl tool) | * one for DB creation scripts (they are part of kamctl tool) | ||
+ | |||
+ | This brings the benefit of easy backporting, | ||
+ | |||
+ | If there is a fix that has to be backported, always do it to master branch and then cherry-pick it in the stable branches. With split commits, the typical backport procedure is: | ||
+ | * cherry-pick only the commit to xml files | ||
+ | * regenerated the schema for the stable branch and commit the updates | ||