Skip to content

Commit

Permalink
Merge pull request datakaveri#469 from shreelakshmijoshi/creating-dmp…
Browse files Browse the repository at this point in the history
…-audit-table

Create DMP Audit table
  • Loading branch information
pranavrd authored Jan 15, 2024
2 parents 8b93d98 + 5d444d7 commit a714cb3
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
-- Creating audit table for Data MarketPlace server
---


CREATE TABLE IF NOT EXISTS auditing_dmp
(
_id uuid DEFAULT uuid_generate_v4 () NOT NULL PRIMARY KEY,
user_id uuid NOT NULL,
api varchar NOT NULL,
method varchar NOT NULL,
info JSON NOT NULL,
time timestamp without time zone NOT NULL,
created_at timestamp without time zone NOT NULL,
modified_at timestamp without time zone NOT NULL
);

ALTER TABLE auditing_dmp OWNER TO ${flyway:user}

--
-- Triggers
--
CREATE TRIGGER update_auditing_dmp_created BEFORE INSERT ON auditing_dmp FOR EACH ROW EXECUTE PROCEDURE update_created();
CREATE TRIGGER update_auditing_dmp_modified BEFORE INSERT OR UPDATE ON auditing_dmp FOR EACH ROW EXECUTE procedure update_modified();

--
-- Index
--
CREATE INDEX auditing_dmp_user_id_index ON auditing_dmp USING HASH (user_id);

--
-- Grants
--

GRANT USAGE ON SCHEMA ${flyway:defaultSchema} TO ${rsUser};
GRANT SELECT,INSERT,UPDATE,DELETE ON TABLE auditing_dmp TO ${rsUser};

0 comments on commit a714cb3

Please sign in to comment.