Skip to content

Migrate remaining ONPRC modules' SQL scripts to PostgreSQL - #1859

Open
labkey-adam wants to merge 11 commits into
release26.3-SNAPSHOTfrom
26.3_fb_final_onprc_scripts
Open

Migrate remaining ONPRC modules' SQL scripts to PostgreSQL#1859
labkey-adam wants to merge 11 commits into
release26.3-SNAPSHOTfrom
26.3_fb_final_onprc_scripts

Conversation

@labkey-adam

@labkey-adam labkey-adam commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Rationale

Consolidate and migrate SQL upgrade scripts in the last three ONPRC modules:

  • extscheduler
  • onprc_ehr_compliancedb
  • onprc_ssu

Tasks

  • Claude Code Review
  • Code Review

@labkey-adam

Copy link
Copy Markdown
Contributor Author

@ankurjuneja @labkey-martyp note the TODO in extscheduler-0.000-25.000.sql. There's a very fishy interval in procedure extBlockOutEvening(). Probably need to discuss with ONPRC to fix this or remove it if it's no longer used.

@labkey-adam labkey-adam added this to the 26.03 milestone Aug 22, 2026
ankurjuneja
ankurjuneja previously approved these changes Aug 24, 2026
The ExtScheduler overlap trigger carried the T-SQL spelling `PropertySets."Set"` into PostgreSQL, where the column is declared unquoted and therefore folds to lowercase `set`. Quoted identifiers are matched exactly, so the join referenced a column that does not exist. plpgsql does not plan a function body until first execution, so the install succeeded and every subsequent insert or update of an extscheduler.events row would have failed.

`p_SciShieldToPrimeProcess` and `p_ComplianceTranslatestringUpdate` relied on SQL Server's case-insensitive default collation. The SciShield import lowercases the employee id before matching, which found nothing on PostgreSQL and silently marked every incoming record as an invalid employee id; the lookups now compare with `lower()` on both sides and the insert writes the spelling stored in ehr_compliancedb.employees so the completiondates foreign key resolves. The "arrs" to "DCM" rename now uses `ILIKE` and `regexp_replace(..., 'gi')` so it reaches values that are not already lowercase.

Container EntityIds are a native `uniqueidentifier` on SQL Server but a `VARCHAR(36)` domain on PostgreSQL, and LabKey generates them in lowercase, so the hardcoded uppercase GUID literals matched nothing and wrote rows into a container that resolves to no folder. Lowercased in the PostgreSQL scripts only; the SQL Server scripts are correct as written.
…dures

The two report procedures join ehr_compliancedb.employeeperunit to ehr_compliancedb.requirementspercategory on `unit` or `category`. requirementspercategory constrains both columns with foreign keys to unit_names and employeecategory, but employeeperunit has no constraints at all, so its values are uncontrolled free text. SQL Server's case-insensitive collation absorbed any drift; on PostgreSQL a `DCM` against a `dcm` silently drops the employee from the compliance report rather than raising anything.

Applied to all six joins in each of the bootstrap and 25.000-25.001 scripts. NULL behavior is unchanged: employeeperunit.unit and .category are nullable, and `lower(NULL) = lower(NULL)` is NULL just as `NULL = NULL` was.
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.

3 participants