
CREATE TABLE "trackstatus"( 
    "id"                     bigserial PRIMARY KEY,
    "instructions"           VARCHAR NOT NULL,
    "comment"                VARCHAR  NULL,
    "user_id"                INT NOT NULL,
    "exportcompany_id"       INT NOT NULL,
    "created_at"             TIMESTAMPTZ NOT NULL DEFAULT(now())
);

CREATE TABLE "interceptionnotice"( 
    "id"                     bigserial PRIMARY KEY,
    "consignment_no"         VARCHAR NOT NULL,
    "instructions"           VARCHAR  NULL,
    "notes"                  VARCHAR  NULL,
    "user_id"                INT NOT NULL,
    "exportcompany_id"       INT NOT NULL,
    "created_at"             TIMESTAMPTZ NOT NULL DEFAULT(now())
);

CREATE TABLE "destructionnotice"( 
    "id"                     bigserial PRIMARY KEY,
    "consignment_no"         VARCHAR NOT NULL,
    "instructions"           VARCHAR  NULL,
    "notes"                  VARCHAR  NULL,
    "user_id"                INT NOT NULL,
    "boarder_inspector"      INT NOT NULL,
    "nppo_inspector"         INT NOT NULL,
    "company_rep"            INT NOT NULL,
    "exportcompany_id"       INT NOT NULL,
    "created_at"             TIMESTAMPTZ NOT NULL DEFAULT(now())
);

ALTER TABLE "destructionnotice" ADD FOREIGN KEY ("user_id") REFERENCES "users" ("id");
ALTER TABLE "destructionnotice" ADD FOREIGN KEY ("boarder_inspector") REFERENCES "users" ("id");
ALTER TABLE "destructionnotice" ADD FOREIGN KEY ("nppo_inspector") REFERENCES "users" ("id");
ALTER TABLE "destructionnotice" ADD FOREIGN KEY ("company_rep") REFERENCES "users" ("id");
ALTER TABLE "destructionnotice" ADD FOREIGN KEY ("exportcompany_id") REFERENCES "exportcompanies" ("id");