CREATE TABLE pbs (
    id INTEGER PRIMARY KEY,
	attribute TEXT,
	val TEXT
);

INSERT INTO pbs (attribute, val) VALUES ("version", "0.1");
INSERT INTO pbs (attribute, val) VALUES ("location", "http://pbs.lan/");
INSERT INTO pbs (attribute, val) VALUES ("uclibrootfs-version", "1");

CREATE TABLE systems (
	id INTEGER PRIMARY KEY,
	external_id TEXT,
	append TEXT,
	description TEXT,
	initrd TEXT,
	kernel TEXT,
	name TEXT,
	source TEXT
);

CREATE TABLE sources (
    ip TEXT PRIMARY KEY,
    version TEXT,
    lastdemux TEXT,
    description TEXT
);

CREATE TABLE kernels (
	id INTEGER PRIMARY KEY,
	kernel TEXT,
    kernel_md5 TEXT,
    initramfs_md5 TEXT
);

CREATE TABLE bootmedia (
	id INTEGER PRIMARY KEY,
	kernel TEXT,
	name TEXT,
	identifier TEXT,
	description TEXT,
	created TEXT,
	theme TEXT,
	mediatype TEXT
);

CREATE TABLE menus (
	id INTEGER PRIMARY KEY,
	name TEXT,
	description TEXT,
	theme TEXT
);

CREATE TABLE menu_entries (
    id INTEGER PRIMARY KEY,
	menu_id INTEGER,
	entry_order INTEGER,
	system_id INTEGER,
	overwrite_caption INTEGER,
	overwrite_append INTEGER,
	alternative_caption TEXT,
	alternative_append TEXT
);

CREATE TABLE menu_assignments (
    id INTEGER PRIMARY KEY,
    name TEXT,
    menu_id INTEGER
);

CREATE TABLE menu_assignment_iprules (
    id INTEGER PRIMARY KEY,
    menu_assignment_rule INTEGER,
    ip TEXT,
    netmask TEXT
);

CREATE TABLE menu_assignment_bmrules (
    id INTEGER PRIMARY KEY,
    menu_assignment_rule INTEGER,
    bootmedia_id INTEGER
);

