schema.sql (1246B)
1 -- categories table 2 CREATE TABLE IF NOT EXISTS categories ( 3 id integer PRIMARY KEY, 4 name text NOT NULL 5 ); 6 7 -- storages table 8 CREATE TABLE IF NOT EXISTS storages ( 9 id integer PRIMARY KEY, 10 name text NOT NULL 11 ); 12 13 -- parts table 14 CREATE TABLE IF NOT EXISTS parts ( 15 id integer PRIMARY KEY, 16 mpn text, 17 manufacturer text, 18 description text, 19 specs text, 20 footprint text, 21 category_id integer NOT NULL, 22 storage_id integer NOT NULL, 23 quantity integer NOT NULL DEFAULT 0, 24 datasheet blob, 25 image blob, 26 part_type text, 27 insert_date text NOT NULL DEFAULT (datetime('now','localtime')), 28 update_date text NOT NULL DEFAULT (datetime('now','localtime')), 29 FOREIGN KEY (category_id) REFERENCES categories (id), 30 FOREIGN KEY (storage_id) REFERENCES storages (id) 31 ); 32 33 -- parts_histoy table 34 CREATE TABLE IF NOT EXISTS parts_history ( 35 id integer PRIMARY KEY, 36 part_id integer NOT NULL, 37 insert_date text NOT NULL DEFAULT (datetime('now','localtime')), 38 movement integer NOT NULL, 39 mcomment text, 40 FOREIGN KEY (part_id) REFERENCES parts (id) 41 ); 42 43 -- metadata table 44 CREATE TABLE IF NOT EXISTS metadata ( 45 id integer PRIMARY KEY, 46 name text NOT NULL, 47 value text NOT NULL 48 );