CREATE TABLE audit_logs (
    id BIGSERIAL PRIMARY KEY,
    table_name VARCHAR(100) NOT NULL,
    record_id BIGINT NOT NULL,
    action VARCHAR(30) NOT NULL,
    before_data JSONB,
    after_data JSONB,
    changed_by BIGINT,
    created_at TIMESTAMPTZ DEFAULT now()
);

ALTER TABLE audit_logs
ADD CONSTRAINT fk_changed_by FOREIGN KEY (changed_by) REFERENCES users (id);