Files
mctf/dark-tariff/backend/database/sql/schema/billing.sql
T

27 lines
922 B
SQL
Executable File

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,
failed_checks integer not null default 0
);
alter table billing.reading
add column if not exists failed_checks integer not null default 0;
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'));