CREATE TABLE "orchestration_session" (
"orchestration_session_id" VARCHAR PRIMARY KEY NOT NULL,
"device_id" VARCHAR NOT NULL,
"orchestration_nature_id" TEXT NOT NULL,
"version" TEXT NOT NULL,
"orch_started_at" TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
"orch_finished_at" TIMESTAMPTZ,
"elaboration" TEXT CHECK(json_valid(elaboration) OR elaboration IS NULL),
"args_json" TEXT CHECK(json_valid(args_json) OR args_json IS NULL),
"diagnostics_json" TEXT CHECK(json_valid(diagnostics_json) OR diagnostics_json IS NULL),
"diagnostics_md" TEXT,
FOREIGN KEY("device_id") REFERENCES "device"("device_id"),
FOREIGN KEY("orchestration_nature_id") REFERENCES "orchestration_nature"("orchestration_nature_id")
)