-- MySQL Database Schema for GT 4.0 RFT service

create table requestid
(
    request_id int not null,
    constraint requestid_pk_cons primary key(request_id)
);

create table transferid 
(
    transfer_id int not null, 
    constraint transferid_pk_cons primary key(transfer_id)
);

create table request 
(
    id int not null,
    concurrency int default 1,
    termination_time float,
    proxy_loc   varchar(500),
    username    varchar(200),
    started     bit(1) default 0,
    all_or_none bit(1) default 0,
    maxattempts int default 1,
    delegated_epr   varchar(1200),
    user_subject    varchar(500),
    constraint request_pk_cons primary key(id)
);

create table transfer 
(
    id int not null,
    request_id int not null,
    source_url varchar(500) not null,
    dest_url varchar(500),
    status int default 4,
    attempts int default 0,
    user_name   varchar(500) default null,
    dcau    bit(1) default 0,
    parallel_streams int default 1,
    tcp_buffer_size int default 0,
    block_size int default 16000,
    notpt bit(1) default 0,
    binary_mode bit(1) default 1,
    source_subject varchar(500),
    dest_subject varchar(500),
    retry_time float default 0,
    size float default 0,
    fault varchar(1000),
    permissions int,
    ignore_file_perm_errors bit(1) default 0,
    constraint transfer_pk_cons primary key(id)
);

create table restart
(
    transfer_id int,
    marker  varchar(500)
);

create table factory
(
    total_transfers float,
    total_bytes float
);
