CREATE TABLE audit_logs (
    id          BIGSERIAL PRIMARY KEY,
    operator_id BIGINT NOT NULL REFERENCES users(id),
    tenant_id   BIGINT,
    module      VARCHAR(50) NOT NULL,
    action      VARCHAR(50) NOT NULL,
    before_json JSONB,
    after_json  JSONB,
    result      VARCHAR(20),
    created_at  TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX idx_audit_module_created ON audit_logs(module, created_at DESC);
