Untitled

 avatar
unknown
plain_text
4 months ago
3.2 kB
2
Indexable
create table public.merchants
(
    id           uuid                     default gen_random_uuid() not null
        primary key,
    name         varchar(255)                                       not null,
    address      text,
    phone_number varchar(20),
    created_at   timestamp with time zone default now(),
    updated_at   timestamp with time zone default now(),
    deleted_at   timestamp with time zone
);

alter table public.merchants
    owner to admin;

create table public.guarantee_types
(
    id         serial
        primary key,
    name       varchar(255) not null,
    content    text,
    created_at timestamp with time zone default now(),
    updated_at timestamp with time zone default now(),
    deleted_at timestamp with time zone
);

alter table public.guarantee_types
    owner to admin;

create table public.products
(
    id         uuid                     default gen_random_uuid() not null
        primary key,
    name       varchar(255)                                       not null,
    created_at timestamp with time zone default now(),
    updated_at timestamp with time zone default now(),
    deleted_at timestamp with time zone
);

alter table public.products
    owner to admin;

create table public.series_export
(
    id               uuid                     default gen_random_uuid() not null
        primary key,
    series_number    varchar(255)
        unique,
    product_id       uuid
                                                                        references public.products
                                                                            on delete set null,
    merchant_id      uuid
                                                                        references public.merchants
                                                                            on delete set null,
    dispatch_date    timestamp with time zone,
    created_at       timestamp with time zone default now(),
    updated_at       timestamp with time zone default now(),
    deleted_at       timestamp with time zone,
    guarantee_status integer                  default 0
);

alter table public.series_export
    owner to admin;

create table public.activation_history
(
    id            uuid                     default gen_random_uuid() not null
        primary key,
    series_number varchar(255),
    phone_number  varchar(20),
    created_at    timestamp with time zone default now(),
    updated_at    timestamp with time zone default now(),
    deleted_at    timestamp with time zone
);

alter table public.activation_history
    owner to admin;

create table public.products_guarantee_types
(
    id                serial
        primary key,
    product_id        uuid    not null
        references public.products
            on delete set null,
    guarantee_type_id integer not null
        references public.guarantee_types
            on delete set null,
    created_at        timestamp with time zone default now(),
    updated_at        timestamp with time zone default now(),
    deleted_at        timestamp with time zone
);

alter table public.products_guarantee_types
    owner to admin;

Editor is loading...
Leave a Comment