Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIM-1847: Create User Settings View - Database #164

Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
{ "changeSet": {"author":"mhostettler","id":"87","changes": [
{"sqlFile": {"relativeToChangelogFile": "true", "path": "ddl/tables/cuws.create.verified_yield_grain_basket.sql"}},
{"sqlFile": {"relativeToChangelogFile": "true", "path": "ddl/tables/cuws.alter.verified_yield_summary.sql"}},
{"sqlFile": {"relativeToChangelogFile": "true", "path": "ddl/tables/cuws.create.user_setting.sql"}},
{"sqlFile": {"relativeToChangelogFile": "true", "path": "ddl/grants/cuws.ddl.apply_grants.sql"}}
] } }]}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

--Grant CRUD access to proxy role
GRANT SELECT, INSERT, UPDATE, DELETE ON cuws.verified_yield_grain_basket TO "app_cuws_rest_proxy";
GRANT SELECT, INSERT, UPDATE, DELETE ON cuws.user_setting TO "app_cuws_rest_proxy";

--Grant read only access to all tables for the readonly role
GRANT SELECT ON ALL TABLES IN SCHEMA cuws TO "app_cuws_readonly";
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
\qecho Create user_setting table
CREATE TABLE cuws.user_setting(
underwriting_user_guid varchar(32) NOT NULL,
login_user_guid varchar(32) NOT NULL,
login_user_id varchar(64) NOT NULL,
login_user_type varchar(64) NOT NULL,
given_name varchar(50),
family_name varchar(50),
policy_search_crop_year numeric(4, 0) NOT NULL,
policy_search_insurance_plan_id numeric(9, 0) NOT NULL,
policy_search_office_id numeric(9, 0) NOT NULL,
create_user varchar(64) NOT NULL,
create_date timestamp(0) NOT NULL,
update_user varchar(64) NOT NULL,
update_date timestamp(0) NOT NULL
) TABLESPACE pg_default
;

COMMENT ON COLUMN cuws.user_setting.underwriting_user_guid IS 'Underwriting User Guid is a unique key of an underwriting user '
;
COMMENT ON COLUMN cuws.user_setting.login_user_guid IS 'Login User Guid is a unique key from the authentication for a user.'
;
COMMENT ON COLUMN cuws.user_setting.login_user_id IS 'Login User Id is the user id from the authentication for a user '
;
COMMENT ON COLUMN cuws.user_setting.login_user_type IS 'Login User Type is the user type from the authentication for a user '
;
COMMENT ON COLUMN cuws.user_setting.given_name IS 'Given Name is the given name from the authentication for a user '
;
COMMENT ON COLUMN cuws.user_setting.family_name IS 'Family Name is the family name from the authentication for a user '
;
COMMENT ON COLUMN cuws.user_setting.policy_search_crop_year IS 'Policy Search Crop Year is the user''s preferred crop year to search for on the policy screen'
;
COMMENT ON COLUMN cuws.user_setting.policy_search_insurance_plan_id IS 'Policy Search Insurance Plan Id is the user''s preferred insurance plan to search for on the policy screen.'
;
COMMENT ON COLUMN cuws.user_setting.policy_search_office_id IS 'Policy Search Office Id is the user''s preferred office to search for on the policy screen.'
;
COMMENT ON COLUMN cuws.user_setting.create_user IS 'Create User is the user id of the user that created the record '
;
COMMENT ON COLUMN cuws.user_setting.create_date IS 'Create Date is the date when the record was created '
;
COMMENT ON COLUMN cuws.user_setting.update_user IS 'Update User is the user id of the user that updated the record last'
;
COMMENT ON COLUMN cuws.user_setting.update_date IS 'Update Date is the date when the record was updated last '
;
COMMENT ON TABLE cuws.user_setting IS 'The table contains user''s preferred settings for search '
;

CREATE INDEX ix_us_lug ON cuws.user_setting(login_user_guid)
TABLESPACE pg_default
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indexes for foreign keys insurance plan and office are missing

;
CREATE INDEX ix_us_ip ON cuws.user_setting(policy_search_insurance_plan_id)
TABLESPACE pg_default
;
CREATE INDEX ix_us_of ON cuws.user_setting(policy_search_office_id)
TABLESPACE pg_default
;
ALTER TABLE cuws.user_setting ADD
CONSTRAINT pk_us PRIMARY KEY (underwriting_user_guid) USING INDEX TABLESPACE pg_default
;

ALTER TABLE cuws.user_setting ADD
CONSTRAINT uk_us UNIQUE (login_user_guid) USING INDEX TABLESPACE pg_default
;

ALTER TABLE cuws.user_setting ADD CONSTRAINT fk_us_ip
FOREIGN KEY (policy_search_insurance_plan_id)
REFERENCES cuws.insurance_plan(insurance_plan_id)
;

ALTER TABLE cuws.user_setting ADD CONSTRAINT fk_us_of
FOREIGN KEY (policy_search_office_id)
REFERENCES cuws.office(office_id)
;