osman_cabra_bom.sql

Original query:

-- create services
create table services
(
    id           integer generated always as identity,
    code         varchar(60),           -- sales part num -- charge type ?? -- statistical services??
    description  varchar(255),
    display_name varchar(255),
    aggregate_type    varchar(255)      -- 'sum', 'avg'
);

-- relationship yards_services
create table yards_services
(
    id                integer generated always as identity,
    service_id        integer,          -- fk
    billing_frequency varchar(255),     -- weekly, bimonthly, monthly, eom
    comment_required  boolean,
    display_order     integer,
    start_date        timestamptz,      -- usually the same as contract, but can vary
    end_date          timestamptz      -- usually the same as contract, but can vary
);

-- create yards_services_values
create table yards_services_values -- ??
(
    id                       integer generated always as identity,
    user_id
    yard_service_id          integer,                               -- fk
    value                    double,
    comment                  text,
);

-- create billing_comments
create table billing_comments (
    id
    yard_id
    date
    text
    user_id
);