--  $HeadURL$ $LastChangedRevision$

PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE host_configurations (
    hostname                 varchar(16)   CHECK (hostname not null),
    vm_flag                  varchar(16)   CHECK (vm_flag == "false" OR  vm_flag == "true"),
    hvm_flag                 varchar(16)   CHECK (hvm_flag == "false" OR  hvm_flag == "true"),
    macaddr                  varchar(18)   CHECK (macaddr not null),
    distro                   varchar(18)   CHECK (distro not null),
    release                  varchar(16)   CHECK (release not null),
    arch                     varchar(16)   CHECK (arch == "i386" OR arch == "amd64"),
    ram                      varchar(16)   CHECK (ram > 0),
    disk                     varchar(16)   CHECK (disk > 0),
    vmserver_hostname        varchar(16)   CHECK (vmserver_hostname not null),
    vm_app                   varchar(16)   CHECK (vm_app == "xen" OR vm_app == "kvm"),
    dhcp_editor              varchar(1024) CHECK (dhcp_editor not null),
    dns_editor               varchar(1024) CHECK (dns_editor not null),
    inprogress_editor        varchar(1024) CHECK (inprogress_editor not null),
    machine_editor           varchar(1024) CHECK (machine_editor not null),
    payload_editor           varchar(1024) CHECK (payload_editor not null),
    preseed_editor           varchar(1024) CHECK (preseed_editor not null),
    pxe_editor               varchar(1024) CHECK (pxe_editor not null),
    repo_editor              varchar(1024) CHECK (repo_editor not null),
    script_editor            varchar(1024) CHECK (script_editor not null),
    storage_editor           varchar(1024) CHECK (storage_editor not null),
    PRIMARY KEY (hostname)
);

CREATE TABLE host_installations (
    hostname                 varchar(16)   CHECK (hostname not null),
    release_cmdline          varchar(1024) CHECK (release_cmdline not null),
    mailto                   varchar(32)   CHECK (mailto not null),
    primary key (hostname),
    foreign key (hostname) references host_configurations(hostname)
);
COMMIT;
