PRAGMA journal_mode=WAL;
PRAGMA foreign_keys=on;

CREATE TABLE "mosservers" (
  "mosId" INTEGER PRIMARY KEY AUTOINCREMENT,
  "mosServer" TEXT
);

-- Default values ... might be omitted later?
INSERT INTO "mosservers" ("mosServer") VALUES
  ("Material.n24test.intern.mos"),
  ("StudioA.n24test.intern.mos"),
  ("Material.n24prod.intern.mos"),
  ("StudioA.n24prod.intern.mos")
;

CREATE TABLE "mosstatus" (
  "statusId" INTEGER PRIMARY KEY AUTOINCREMENT,
  "status" TEXT
);

INSERT INTO "mosstatus" ("status") VALUES
  ("NEW"),
  ("UPDATED"),
  ("MOVED")
;

CREATE TABLE "mosair" (
  "airId" INTEGER PRIMARY KEY AUTOINCREMENT,
  "objAir" TEXT
);

INSERT INTO "mosair" ("objAir") VALUES
  ("READY"),
  ("NOT READY")
;

CREATE TABLE "mosgroups" (
  "groupId" INTEGER PRIMARY KEY AUTOINCREMENT,
  "objGroup" TEXT
);

CREATE TABLE "mosobjects" (
  "objId" TEXT PRIMARY KEY,
  "mosId" INTEGER REFERENCES "mosservers" ("mosId"),
  "statusId" INTEGER REFERENCES "mosstatus" ("statusId"),
  "objSlug" TEXT,
  "objPath" TEXT,
  "objAir" INTEGER REFERENCES "mosair" ("airId"),
  "created" INTEGER,
  "createdBy" TEXT,
  "changed" INTEGER,
  "changedBy" TEXT,
  "groupId" INTEGER REFERENCES "mosgroups" ("groupId")
);

CREATE TABLE "mosobjlinks" (
    "objId" TEXT PRIMARY KEY,
    "planningId" TEXT
);

CREATE TABLE "todo" (
  "objId" TEXT PRIMARY KEY
);
