Skip to content

Database

Show schema of the database and compare with the schema of the application.

HTTP
curl {{host}}/api/core/apps/db-schema/{{app_name}} \
-H "Authorization: Token {{token}}" 

file structure

XML
1
2
3
4
5
<srs>
  <db>
    <itm model="db-index-exist" name="[dbo].[invoice].[IX_payer]">CREATE INDEX IX_payer ON [dbo].[invoice] (payerid)</itm>
  </db>
</srs>

compare scripts

Schema of the database is stored in the db directory of the application. You can use any folder structure.

For comparing Functions,Views, Procedures, you need to put CREATE script files in the db directory. File name must be in the format schema.objectname.sql.

db checks

Additionally you can put special file db-checks.xml in the db directory. This file contains macro for the database schema.

Macros:

db-index-exist

XML
 <itm model="db-index-exist" name="[document].[invoice].[IX_document_payerid]">CREATE INDEX IX_document_payerid ON document.invoice (payerid);</itm>

db-table-exist

XML
1
2
3
4
5
6
7
8
9
<itm model="db-table-exist" name="[document].[documentComputed]">
<![CDATA[       
CREATE TABLE [document].[documentComputed]
(
    [documentID] [uniqueidentifier] NOT NULL,
    [itemQuantity] [decimal](18, 4) NULL
)
]]>
</itm>

db-columns-sync

additionally you can put value for initial values of the columns

XML
1
2
3
4
5
<itm model="db-column-sync" name="system">
  <col name="[app].[mail].[mail_team_id]" type="uniqueidentifier" isnull="NULL" />
  <col name="[app].[mail].[mail_sent]" type="smalldatetime" isnull="NULL" />
  <col name="[app].[mail].[mail_date]" type="datetime" isnull="NULL" > --update [app].[mail] set  [mail_date]  = null</col>
</itm>