Skip to content

meta_data.json description

Oleg Gurov edited this page Sep 19, 2020 · 18 revisions

Any package (packet) can have a meta_data.json file that defines execution settings.

The meta_data.json contains information about the current packet and provides the ability to send output of db_converter to messenger or other functionality. The current implementation supports only mattermost integration.

General structure of meta_data.json:

{
    "type": < "default" | "read_only" | "no_commit" | "maintenance" | "export_data" >,
    "client_min_messages": < "DEBUG1" | "LOG" | "NOTICE" | "WARNING" | "ERROR" >,
    "export_options": {
        "use_zip": < "yes" | "no" >
        "password": < "random" | "123456" >
    },
    "hook": {
        "type": < "matterhook" | "slack" >,
        "username": text,
        "verbosity": [ "resultset" | "stm_result" | "raise" | "all" ],
        "channel": text,
        "message": text
    },
    "postgresql": {
        "statement_timeout": "180s"
    }
}

The client_min_messages field initializes the corresponding session variable and determines what level of messages will be displayed in the console during packet deployment:

Value Description
ERROR Only errors are displayed
WARNING This mode is used by default. Warnings and errors are displayed.
NOTICE The raise notice is displayed, plus the above
LOG The raise log is displayed, plus the above
DEBUG1...DEBUG5 Debug mode

Packet types

Possible values of type field:

Value Action tracker Description
default Yes If the type field is not initialized or has the value default, then the package is tracked in the target database during deployment. The entire content of meta_data.json will be written to dbc_packets.meta_data
read_only No The transaction will be opened in SET TRANSACTION READ ONLY mode. This mode can be used to implement notifications when the DB state does not change. When launching packet of this type, the execution result is not recorded in the target database, i.e. the packet can be launched an unlimited number of times. Read only packet example.
no_commit No The transaction of this packet type is rolled back. The result of the execution is not recorded. This mode is appropriate for implementing notifications when the state of the database does not change, but auxiliary temporary tables are required during the execution of the query. Example of no_commit.
maintenance No A package of this type can change the database structure and data, but the deployment result is not recorded. This mode is appropriate for implementing periodic database maintenance, for example, clearing old data. See example.
export_data No The transaction will be opened in SET TRANSACTION READ ONLY mode. Deployment result is not recorded to Action tracker. A package of this type should only have SELECT queries. The results of queries will be saved to files of the same name, taking into account the export settings - section export_options. Example of export_data

Hooks

The hook object contains a description of interaction with the messenger. Previously, the matterhook section of db_converter.conf file must be configured, for example:

[matterhook]
url = https://mm.site.org
chat_keys = dbc-dba/973cq47o6tbhtnqwbibdduqkbi

How to set up meta_data.json and incoming hooks in mattermost:

 

 

The behavior of output to messenger is determined by hook.verbosity parameter (an array of the following values):

Clone this wiki locally