-- wayleave_07_access_log.sql
-- Mirrors projects.project_access_log for wayleave agreements.
-- Run once against the netplanner database.

CREATE TABLE IF NOT EXISTS wayleave.agreement_access_log (
    id              bigserial PRIMARY KEY,
    agreement_id    integer NOT NULL REFERENCES wayleave.agreements(agreement_id),
    user_id         integer,
    access_type     character varying(50),
    access_datetime timestamp without time zone DEFAULT now()
);

CREATE INDEX IF NOT EXISTS idx_agreement_access_log_agreement ON wayleave.agreement_access_log(agreement_id);
CREATE INDEX IF NOT EXISTS idx_agreement_access_log_user      ON wayleave.agreement_access_log(user_id);
