CREATE TABLE IF NOT EXISTS {SCHEMA_NAME}.events (

id          BIGSERIAL PRIMARY KEY,
postjob_id  BIGINT REFERENCES {SCHEMA_NAME}.postjobs ON DELETE SET NULL,
host_id     UUID NOT NULL REFERENCES {SCHEMA_NAME}.hosts ON DELETE CASCADE,
worker_session_id  UUID REFERENCES {SCHEMA_NAME}.worker_sessions ON DELETE SET NULL,
name        VARCHAR NOT NULL,
attributes  JSONB not null DEFAULT '{}'::JSONB,
created_at  timestamp NOT NULL DEFAULT (now() at time zone 'utc')

);

– We do not create an index on events.attributes just yet. events has a high – write rate, and until we know for sure that we'll need this index we – better not have it.