chore: import MCTF services
- Added all seven issued service trees without omissions. - Preserved the supplied runtime configuration, binaries, and assets.
This commit is contained in:
commit
13f936bee9
1222 files changed
+21280
No files matched your search
+22
@@ -0,0 +1,22 @@
|
||||
create extension if not exists pgcrypto;
|
||||
|
||||
create schema if not exists billing;
|
||||
|
||||
create table if not exists billing.reading (
|
||||
id bigserial primary key,
|
||||
serial text not null check (btrim(serial) <> '' and length(serial) <= 128),
|
||||
kind text not null,
|
||||
metrics jsonb not null check (jsonb_typeof(metrics) = 'object'),
|
||||
created_at timestamptz not null default now(),
|
||||
n integer not null,
|
||||
h bit varying[] not null,
|
||||
y bit varying not null,
|
||||
w integer not null,
|
||||
parameters text not null
|
||||
);
|
||||
|
||||
create index if not exists reading_created_at_idx
|
||||
on billing.reading (created_at);
|
||||
|
||||
create unique index if not exists reading_parameters_uniq
|
||||
on billing.reading (digest(parameters, 'sha256'));
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
create schema if not exists chat;
|
||||
|
||||
create table if not exists chat.check_session (
|
||||
id uuid primary key default gen_random_uuid(),
|
||||
reading_id bigint not null references billing.reading (id) on delete cascade,
|
||||
round integer not null default 1 check (round between 1 and 10),
|
||||
challenge integer check (challenge between 0 and 2),
|
||||
data text[],
|
||||
complete boolean not null default false
|
||||
);
|
||||
|
||||
create index if not exists check_session_reading_idx on chat.check_session (reading_id);
|
||||
@@ -0,0 +1,7 @@
|
||||
create table if not exists billing.receipt (
|
||||
id bigserial primary key,
|
||||
reading_id bigint not null unique references billing.reading (id) on delete cascade,
|
||||
created_at timestamptz not null default now(),
|
||||
key_digest bytea not null check (octet_length(key_digest) = 32),
|
||||
data jsonb not null
|
||||
);
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
create table if not exists billing.report_field (
|
||||
id text primary key,
|
||||
title text not null,
|
||||
expression text not null,
|
||||
aggregate boolean not null default false,
|
||||
report_types text[] not null default '{}',
|
||||
position integer not null,
|
||||
created_at timestamptz not null default now()
|
||||
);
|
||||
|
||||
insert into billing.report_field (id, title, expression, aggregate, report_types, position) values
|
||||
('period', 'Период', $field$to_char(r.created_at, 'YYYY-MM')$field$, false, '{finance}', 10),
|
||||
('resource', 'Ресурс', $field$coalesce((select item->>'title' from jsonb_array_elements(billing.resource_types()) item where item->>'id' = r.kind), r.kind)$field$, false, '{finance}', 20),
|
||||
('tariff', 'Тариф', $field$(c.data->'calculation'->>'unit_price')::numeric$field$, false, '{finance}', 30),
|
||||
('quantity', 'Количество', $field$sum((c.data->'calculation'->>'quantity')::numeric)$field$, true, '{finance}', 40),
|
||||
('amount', 'Сумма', $field$sum((c.data->'calculation'->>'amount')::numeric)$field$, true, '{finance}', 50),
|
||||
('readings', 'Показаний', 'count(*)', true, '{finance}', 60)
|
||||
on conflict (id) do update set title = excluded.title, expression = excluded.expression,
|
||||
aggregate = excluded.aggregate, report_types = excluded.report_types, position = excluded.position;
|
||||
Reference in new issue
Block a user