CREATE TABLE "surveilr_osquery_ms_node" (
"surveilr_osquery_ms_node_id" VARCHAR PRIMARY KEY NOT NULL,
"node_key" TEXT NOT NULL,
"host_identifier" TEXT NOT NULL,
"tls_cert_subject" TEXT,
"os_version" TEXT NOT NULL,
"platform" TEXT NOT NULL,
"last_seen" TIMESTAMP NOT NULL,
"status" TEXT NOT NULL DEFAULT 'active',
"osquery_version" TEXT,
"osquery_build_platform" TEXT NOT NULL,
"device_id" VARCHAR NOT NULL,
"behavior_id" VARCHAR,
"created_at" TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
"created_by" TEXT DEFAULT 'UNKNOWN',
"updated_at" TIMESTAMPTZ,
"updated_by" TEXT,
"deleted_at" TIMESTAMPTZ,
"deleted_by" TEXT,
"activity_log" TEXT,
FOREIGN KEY("device_id") REFERENCES "device"("device_id"),
FOREIGN KEY("behavior_id") REFERENCES "behavior"("behavior_id"),
UNIQUE("host_identifier", "os_version"),
UNIQUE("node_key")
)