-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: catherine meng <[email protected]>
- Loading branch information
1 parent
c60f28b
commit 15c513d
Showing
3 changed files
with
139 additions
and
158 deletions.
There are no files selected for viewing
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
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
61 changes: 61 additions & 0 deletions
61
server/flyway/sql/V36__add_access_control_privilege_table.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,61 @@ | ||
-- Create fam_access_control_privilege table | ||
CREATE TABLE IF NOT EXISTS app_fam.fam_access_control_privilege | ||
( | ||
access_control_privilege_id bigint GENERATED BY DEFAULT AS IDENTITY (START WITH 1 INCREMENT BY 1), | ||
user_id bigint NOT NULL, | ||
role_id bigint NOT NULL, | ||
create_user varchar(60) NOT NULL, | ||
create_date timestamp(6) DEFAULT CURRENT_DATE NOT NULL, | ||
update_user varchar(60), | ||
update_date timestamp(6) DEFAULT CURRENT_DATE | ||
); | ||
|
||
-- Add table/column comments | ||
COMMENT ON TABLE app_fam.fam_access_control_privilege IS 'Access Control Privilege is a cross-reference object that allows for the identification of who are the delegated administrators(User) for an Application for a particular role.' | ||
; | ||
COMMENT ON COLUMN app_fam.fam_access_control_privilege.access_control_privilege_id IS 'Automatically generated key used to identify the uniqueness of a User administers the Application role.' | ||
; | ||
COMMENT ON COLUMN app_fam.fam_access_control_privilege.user_id IS 'Unique ID to reference and identify the user within FAM system.' | ||
; | ||
COMMENT ON COLUMN app_fam.fam_access_control_privilege.role_id IS 'Unique ID to reference and identify the application role within FAM system.' | ||
; | ||
COMMENT ON COLUMN app_fam.fam_access_control_privilege.create_user IS 'The user or proxy account that created the record.' | ||
; | ||
COMMENT ON COLUMN app_fam.fam_access_control_privilege.create_date IS 'The date and time the record was created.' | ||
; | ||
COMMENT ON COLUMN app_fam.fam_access_control_privilege.update_user IS 'The user or proxy account that created or last updated the record.' | ||
; | ||
COMMENT ON COLUMN app_fam.fam_access_control_privilege.update_date IS 'The date and time the record was created or last updated.' | ||
; | ||
|
||
-- Create index | ||
CREATE INDEX ix_app_fam_fam_access_control_privilege_user_id ON app_fam.fam_access_control_privilege (user_id) | ||
; | ||
CREATE INDEX ix_app_fam_fam_access_control_privilege_role_id ON app_fam.fam_access_control_privilege (role_id) | ||
; | ||
CREATE UNIQUE INDEX fam_access_control_usr_rle_uk ON app_fam.fam_access_control_privilege(user_id, role_id) | ||
; | ||
|
||
-- Add constraints | ||
ALTER TABLE app_fam.fam_access_control_privilege ADD CONSTRAINT fam_access_control_privilege_pk PRIMARY KEY (access_control_privilege_id) | ||
; | ||
ALTER TABLE app_fam.fam_access_control_privilege ADD CONSTRAINT Reffam_access_control_privilege_user | ||
FOREIGN KEY (user_id) | ||
REFERENCES app_fam.fam_user(user_id) | ||
; | ||
ALTER TABLE app_fam.fam_access_control_privilege ADD CONSTRAINT Reffam_access_control_privilege_role | ||
FOREIGN KEY (role_id) | ||
REFERENCES app_fam.fam_role(role_id) | ||
; | ||
|
||
-- Grant privileges for Admin Management API | ||
GRANT SELECT, UPDATE, DELETE, INSERT ON app_fam.fam_access_control_privilege TO ${admin_management_api_db_user} | ||
; | ||
-- -- on 'fam_role' for Read only. | ||
GRANT SELECT ON app_fam.fam_role TO ${admin_management_api_db_user} | ||
; | ||
|
||
-- Grant SELECT privilege to Auth Lambda | ||
GRANT SELECT ON app_fam.fam_access_control_privilege TO ${auth_lambda_db_user} | ||
; | ||
|