   -- Number of levels
   depth INTEGER,
   -- SBS specific columns
-  state INTEGER DEFAULT 0,
+  state INTEGER  NOT NULL DEFAULT 0,
   -- production number given by the erp system. We should really use
   -- this as the primary key but alas some productions are done
   -- without involving the erp system, so we need to keep our own

);

CREATE TABLE user (
  id INTEGER PRIMARY KEY,
  username TEXT NOT NULL,
  first_name TEXT NOT NULL,
  last_name TEXT NOT NULL,

);

CREATE TABLE role (
  id INTEGER AUTO_INCREMENT PRIMARY KEY,
  name TEXT NOT NULL
);

CREATE TABLE user_role (
  id INTEGER AUTO_INCREMENT PRIMARY KEY,
  user_id INTEGER NOT NULL,
  role_id INTEGER NOT NULL,
  FOREIGN KEY(user_id) REFERENCES user(id),
