Changeset View
Changeset View
Standalone View
Standalone View
swh/vault/sql/30-schema.sql
create table if not exists dbversion | create table if not exists dbversion | ||||
( | ( | ||||
version int primary key, | version int primary key, | ||||
release timestamptz not null, | release timestamptz not null, | ||||
description text not null | description text not null | ||||
); | ); | ||||
comment on table dbversion is 'Schema update tracking'; | comment on table dbversion is 'Schema update tracking'; | ||||
insert into dbversion (version, release, description) | insert into dbversion (version, release, description) | ||||
values (1, now(), 'Initial version'); | values (4, now(), 'Initial version'); | ||||
create domain obj_hash as bytea; | create domain obj_hash as bytea; | ||||
create type cook_type as enum ('directory', 'revision_gitfast'); | create type bundle_type as enum ('flat', 'gitfast', 'git_bare'); | ||||
comment on type cook_type is 'Type of the requested bundle'; | comment on type bundle_type is 'Type of the requested bundle'; | ||||
create type cook_status as enum ('new', 'pending', 'done', 'failed'); | create type cook_status as enum ('new', 'pending', 'done', 'failed'); | ||||
comment on type cook_status is 'Status of the cooking'; | comment on type cook_status is 'Status of the cooking'; | ||||
create table vault_bundle ( | create table vault_bundle ( | ||||
id bigserial primary key, | id bigserial primary key, | ||||
type cook_type not null, -- requested cooking type | type bundle_type not null, | ||||
object_id obj_hash not null, -- requested object ID | swhid text not null, -- requested object ID | ||||
task_id integer, -- scheduler task id | task_id integer, -- scheduler task id | ||||
task_status cook_status not null default 'new', -- status of the task | task_status cook_status not null default 'new', -- status of the task | ||||
sticky boolean not null default false, -- bundle cannot expire | sticky boolean not null default false, -- bundle cannot expire | ||||
ts_created timestamptz not null default now(), -- timestamp of creation | ts_created timestamptz not null default now(), -- timestamp of creation | ||||
ts_done timestamptz, -- timestamp of the cooking result | ts_done timestamptz, -- timestamp of the cooking result | ||||
ts_last_access timestamptz not null default now(), -- last access | ts_last_access timestamptz not null default now(), -- last access | ||||
progress_msg text -- progress message | progress_msg text -- progress message | ||||
); | ); | ||||
create unique index concurrently vault_bundle_type_object | create unique index concurrently vault_bundle_type_swhid | ||||
on vault_bundle (type, object_id); | on vault_bundle (type, swhid); | ||||
create index concurrently vault_bundle_task_id | create index concurrently vault_bundle_task_id | ||||
on vault_bundle (task_id); | on vault_bundle (task_id); | ||||
create table vault_notif_email ( | create table vault_notif_email ( | ||||
id bigserial primary key, | id bigserial primary key, | ||||
email text not null, -- e-mail to notify | email text not null, -- e-mail to notify | ||||
bundle_id bigint not null references vault_bundle(id) on delete cascade | bundle_id bigint not null references vault_bundle(id) on delete cascade | ||||
); | ); | ||||
Show All 15 Lines |