Add reusable user list schema support#160
Conversation
|
I pulled this over to a Nebula VM and was able to build and test it. Wanting to build a CDA target next to it and test further. Submitting what I have while I work on it so we can discuss! |
MikeNeilson
left a comment
There was a problem hiding this comment.
Looks like a reasonable start.
| on u.user_id = m.userid; | ||
|
|
||
| begin | ||
| execute immediate 'grant select on av_user_list_members to cwms_user'; |
There was a problem hiding this comment.
you can ditch the pl/sql anonymous block here, the direct grant ... should work fine.
| ( | ||
| DB_OFFICE_CODE NUMBER NOT NULL, | ||
| USER_LIST_ID VARCHAR2(128) NOT NULL, | ||
| USER_LIST_DESC VARCHAR2(256), |
There was a problem hiding this comment.
I'd give at least 1024 for the description, if not near the full 4000 before glob starts to make sense.
| USER_LIST_ID VARCHAR2(128) NOT NULL, | ||
| USER_LIST_DESC VARCHAR2(256), | ||
| OWNED_BY_USERID VARCHAR2(128), | ||
| CREATE_DATE DATE, |
There was a problem hiding this comment.
I've generally prefered the names
created_at and updated_at but either way the amount of words should probably be consistent between these two.
There was a problem hiding this comment.
Also, set the create_date to not null and default of current_timestamp, also it should be "timestamp" not date... especially for that portability.
last_update_date should be updated by a simple trigger. (no need to avoid triggers, they can save a lot of hassle, especially for things like this.)
| (DB_OFFICE_CODE, USER_LIST_ID) | ||
| LOGGING | ||
| TABLESPACE CWMS_20AT_DATA | ||
| PCTFREE 10 |
There was a problem hiding this comment.
you can generally ditch all of the elements after tablespace. These are all the defaults anyways.
|
|
||
| CREATE TABLE AT_USER_LIST_MEMBERS | ||
| ( | ||
| DB_OFFICE_CODE NUMBER NOT NULL, |
There was a problem hiding this comment.
Unless a user is going to have a membership to a list per-office, this is not necessary.
As this is a join table the data set is already going to be reduced by some external constraint and sense a given list could reasonably have users from another office it doesn't make sense to limit queries in that way on this table.
| DB_OFFICE_CODE NUMBER NOT NULL, | ||
| USER_LIST_ID VARCHAR2(128) NOT NULL, | ||
| USERID VARCHAR2(128) NOT NULL, | ||
| ADD_DATE DATE, |
There was a problem hiding this comment.
date -> time
| ADD_DATE DATE, | |
| ADD_DATE TIMESTAMP NOT NULL DEFAULT current_timestamp, |
NOTE: I'm pretty sure that current timestamp thing works and doesn't just use the timestamp of when the table was created, but that should be tested, may need to be a trigger.
Closes #159.
Summary
This PR adds database-level support for reusable user lists without duplicating user records and without introducing new PL/SQL.
What Changed
AT_USER_LISTSto store office-scoped user list definitionsAT_USER_LIST_MEMBERSto store memberships using existingAT_SEC_CWMS_USERSrowsAV_USER_LIST_MEMBERSto retrieve list membership with user profile fieldsDesign Notes
AT_SEC_CWMS_USERSas the source of truth for user identityContact Data
The retrieval view currently exposes
FULL_NAMEandEMAIL, but the design is intentionally structured so other contact types can be added later without changing the core user-list membership model.Validation
Follow-up
API support for creating, managing, and retrieving user lists can build on top of these schema objects in
cwms-data-api.