Skip to content

Add reusable user list schema support#160

Draft
krowvin wants to merge 2 commits into
HydrologicEngineeringCenter:mainfrom
krowvin:user-lists
Draft

Add reusable user list schema support#160
krowvin wants to merge 2 commits into
HydrologicEngineeringCenter:mainfrom
krowvin:user-lists

Conversation

@krowvin
Copy link
Copy Markdown
Contributor

@krowvin krowvin commented May 15, 2026

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

  • Added AT_USER_LISTS to store office-scoped user list definitions
  • Added AT_USER_LIST_MEMBERS to store memberships using existing AT_SEC_CWMS_USERS rows
  • Added AV_USER_LIST_MEMBERS to retrieve list membership with user profile fields
  • Wired the new objects into schema build, install, and drop flows
  • Added a design note describing the chosen Option 2 approach

Design Notes

  • Reuses AT_SEC_CWMS_USERS as the source of truth for user identity
  • Keeps user lists separate from the existing security group model
  • Uses plain relational tables and constraints so the design stays portable to PostgreSQL or another RDBMS later
  • Avoids new PL/SQL-specific behavior

Contact Data

The retrieval view currently exposes FULL_NAME and EMAIL, but the design is intentionally structured so other contact types can be added later without changing the core user-list membership model.

Validation

  • Built the schema successfully in the existing install flow on a remote Ubuntu VM
  • Inserted a test user list and membership rows in Oracle
  • Queried the new view and confirmed it returns the expected user identity and email data

Follow-up

API support for creating, managing, and retrieving user lists can build on top of these schema objects in cwms-data-api.

@krowvin krowvin marked this pull request as draft May 15, 2026 21:21
@krowvin
Copy link
Copy Markdown
Contributor Author

krowvin commented May 15, 2026

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!

Copy link
Copy Markdown
Contributor

@MikeNeilson MikeNeilson left a comment

Choose a reason for hiding this comment

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

Looks like a reasonable start.

on u.user_id = m.userid;

begin
execute immediate 'grant select on av_user_list_members to cwms_user';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

date -> time

Suggested change
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add schema support for reusable user lists

2 participants