-CREATE SCHEMA mikkoo;
+CREATE SCHEMA IF NOT EXISTS mikkoo;
 
-CREATE TABLE mikkoo.audit (
+CREATE TABLE IF NOT EXISTS mikkoo.audit (
     message_id   UUID NOT NULL,
     event_id     BIGINT NOT NULL,
     queue        TEXT NOT NULL,

    headers      TEXT,
    published_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE UNIQUE INDEX audit_message_id ON mikkoo.audit (message_id);

COMMENT ON TABLE mikkoo.audit IS 'Logs all messages published to pgq for auditing purposes.';

  RETURN FOUND;
END;
$BODY$;

COMMENT ON FUNCTION mikkoo.delete_audit_record(uuid) IS '
Delete a row from mikkoo.audit
