-
Notifications
You must be signed in to change notification settings - Fork 5
meta_data.json description
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 the output of db_converter to a messenger or other functionality. The current implementation supports only mattermost integration.
The 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": < "mattermost" | "slack" >,
"username": text,
"verbosity": [ "resultset" | "stm_result" | "raise" | "all" ],
"channel": text,
"message": text,
"show_parameters": bool
},
"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 |
The postgresql section allows overriding settings of section postgresql in db_converter.conf file.
Possible values of type field:
| Value | Action tracker | Description |
|---|---|---|
| default | Yes | If the type field is not initialized or has a default value, then a 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 | A 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 a 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 | A transaction of this packet type will be rolled back. The result of an execution is not recorded. This mode is appropriate for implementing notifications when the state of the database does not change, and auxiliary temporary tables are required during the execution of the query. |
| maintenance | No | This type of package can change the database structure and data, but the deployment result will not be recorded. This mode is appropriate for implementing periodic database maintenance, for example, clearing old data. See example. |
| export_data | No | A 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
|
The hook object contains a description of the interaction with the messenger. Previously, the mattermost section of the db_converter.conf file must be configured, for example:
[mattermost]
url = https://mm.site.org
chat_keys = dbc-dba/973cq47o6tbhtnqwbibdduqkbi
How to set up meta_data.json and incoming hooks in mattermost:
The verbosity settings allow to customize of the notifications as well as the amount of information displayed. For example, some notifications can be addressed to all chat participants or someone specific, depending on the step's result.
Consider an example of a one-step packet with the following commands:
do $$
begin
raise notice 'raise notice';
raise warning 'raise warning';
end;
$$;
select version();The behavior of output to the messenger is determined by the hook.verbosity parameter.
"hook"."verbosity": ["resultset"] - displays the result of queries:
{
"type": "read_only",
"hook": {
"type": "mattermost",
"username": "db_converter",
"channel": "dbc-dba",
"verbosity": ["resultset"],
"message": "Current PotgreSQL version:"
}
}
"hook"."verbosity": ["stm_result"] - displays the result of statements:
"hook"."verbosity": ["raise"] - send the results of raise commands to output:
"hook"."verbosity": ["all"] - full output (all of the above cases). The mode is used by default.
To see the result of raise notice in output, add "client_min_messages": "NOTICE":
{
...
"client_min_messages": "NOTICE",
"hook": {
...
"verbosity": ["all"]
}
}