create table group_id
(
    created_at timestamp(6) with time zone,
    updated_at timestamp(6) with time zone,
    group_id   varchar(255),
    id         varchar(255) not null
        primary key
);

create table artifact_id
(
    created_at    timestamp(6) with time zone,
    updated_at    timestamp(6) with time zone,
    artifact_id   varchar(255),
    group_id      varchar(255)
        constraint fkghhaxmc9rw9lhck83y9o6bp1o
            references group_id,
    group_id_long varchar(255),
    id            varchar(255) not null
        primary key
);

create table resource
(
    artifact_id varchar(255),
    group_id    varchar(255),
    id          varchar(255) not null
        primary key,
    version     varchar(255)
);

create table event
(
    timestamp   timestamp(6) with time zone,
    accountid   varchar(255),
    id          varchar(255) not null
        primary key,
    resource_id varchar(255)
        unique
        constraint fkclx5xnhdf2y3l1g3ae6ygsjmf
            references resource,
    type        varchar(255)
        constraint event_type_check
            check ((type)::text = ANY ((ARRAY ['UPLOAD'::character varying, 'DELETE'::character varying])::text[]))
);

create table token
(
    expires_at date,
    created_at timestamp(6) with time zone,
    id         varchar(255) not null
        primary key,
    name       varchar(255),
    token      varchar(255),
    user_id    varchar(255)
);

create table version
(
    pull_count       integer,
    last_pulled      timestamp(6) with time zone,
    artifact_id      varchar(255)
        constraint fklcnjnhvigubmjqng9wt7lcw71
            references artifact_id,
    artifact_id_long varchar(255),
    group_id_long    varchar(255),
    id               varchar(255) not null
        primary key,
    uploaded_by      varchar(255),
    version          varchar(255)
);

create table jar
(
    filename   varchar(255),
    id         varchar(255) not null
        primary key,
    md5        varchar(255),
    sha1       varchar(255),
    url        varchar(255),
    version_id varchar(255)
        constraint fkaf1ctqgugsre652w5465uhjbu
            references version,
    jar        bytea
);

create table pom
(
    filename   varchar(255),
    id         varchar(255) not null
        primary key,
    md5        varchar(255),
    pom        text,
    sha1       varchar(255),
    url        varchar(255),
    version_id varchar(255)
        unique
        constraint fker1jyb1nf0vpmyv5b6ooydplu
            references version
);

