-- preference/form/nc/nc-help/user_event-create.sql
SELECT create_hypertable (
    'audit.user_event',
    'event_time',
    chunk_time_interval => interval '3 days',
    create_default_indexes => false
);

ALTER TABLE audit.user_event SET  (
    timescaledb.compress,
    timescaledb.compress_orderby = 'event_time',
    timescaledb.compress_segmentby = 'session_id,text_value'
);

SELECT  add_compression_policy ('audit.user_event', INTERVAL '7 days');

CREATE INDEX ON "audit"."user_event" ("session_id", "event_time");
