partsdb

electronic parts inventory
git clone https://git.e1e0.net/partsdb.git
Log | Files | Refs | README | LICENSE

schema.sql (1096B)


      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     pn text NOT NULL,
     17     mpn text,
     18     manufacturer text,
     19     description text,
     20     specs text,
     21     footprint text,
     22     category_id integer NOT NULL,
     23     storage_id integer NOT NULL,
     24     quantity integer NOT NULL DEFAULT 0,
     25     datasheet blob,
     26     image blob,
     27     part_type text,
     28     insert_date text NOT NULL DEFAULT CURRENT_TIMESTAMP,
     29     update_date text NOT NULL DEFAULT CURRENT_TIMESTAMP,
     30     FOREIGN KEY (category_id) REFERENCES categories (id),
     31     FOREIGN KEY (storage_id) REFERENCES storages (id)
     32 );
     33 
     34 -- parts_histoy table
     35 CREATE TABLE IF NOT EXISTS parts_history (
     36     id integer PRIMARY KEY,
     37     part_id integer NOT NULL,
     38     insert_date text NOT NULL DEFAULT CURRENT_TIMESTAMP,
     39     movement integer NOT NULL,
     40     mcomment text,
     41     FOREIGN KEY (part_id) REFERENCES parts (id)
     42 );