forked from datakaveri/dx-resource-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request datakaveri#469 from shreelakshmijoshi/creating-dmp…
…-audit-table Create DMP Audit table
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/main/resources/db/migration/V5_7__create_audit_table_for_dmp.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}; |