Mohith 218 hr tables#232
Open
MohithS04 wants to merge 8 commits into
Open
Conversation
Refactor application handling functions and triggers for internal applications. Added timestamps for various fields and created new triggers for internal applications and internal team.
Contributor
There was a problem hiding this comment.
The volunteer application SQL file is for the "Become a Volunteer" feature. The HR table, "Join the team", would have a similar structure of beneficiaries joining the team.
Author
There was a problem hiding this comment.
Hi Pallavi, two quick questions before I finish the HR migration:
- I noticed the updated ddl_volunteer_applications.sql already has an internal_applications branch in updated_at_handler with four separate S3-key timestamp columns (resume, EAD, i20, government_id). I'd been planning a single combined timestamp. Should I match the four-column pattern that's already in the file, or is that section a work-in-progress that's still up for change?
- You mentioned the HR / "Join the Team" feature should follow the structure of beneficiaries joining the team. Can you point me to the beneficiary tables (file path or table names)? That sounds like a closer reference than the volunteer flow I've been copying.
I have the three tables, two functions, and three triggers drafted. Once I have answers to these two, I can finalize and open the PR.
Updated handle_internal_application function to include phone_extension in inserts for both approved and rejected paths. Added trigger definitions for handling updates and enabling triggers for internal applications and team.
MohithS04
commented
Jul 1, 2026
MohithS04
left a comment
Author
There was a problem hiding this comment.
Updated handle_internal_applications, In this SQL file the code describes the Approved Path and Rejected Path. After that It has 3 triggers and enabling them.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Database Objects Created
One ENUM type: internal_app_status_type with four values
Three tables:
internal_applications — live inbox, with all PDF fields plus auto-managed timestamps
internal_app_rejections — audit pile, rejection_id UUID PK, full applicant snapshot plus rejection metadata
internal_team — active members, profile fields plus joined_at, is_active, deactivated_at, internal_role
Indexes on status, reviewer_cognito_id, created_at for HR queue queries
updated_at_handler extended: two new ELSIF branches added for internal_applications and internal_team, dispatched by TG_TABLE_NAME
handle_internal_application created: new function with two mutually exclusive branches (approval, rejection)
Three triggers attached:
trg_internal_app_updated_at — BEFORE UPDATE on internal_applications for timestamps
trg_internal_team_updated_at — BEFORE UPDATE on internal_team for timestamps
trg_handle_internal_application — AFTER UPDATE on internal_applications for state-machine routing
BEFORE UPDATE modifies the row before it's saved (used for timestamp auto-stamping)
AFTER UPDATE runs after the row is committed (used for the migration to other tables and deleting the source)
TG_TABLE_NAME is the magic variable that lets one function serve multiple tables
IS DISTINCT FROM is the null-safe equality check, used everywhere change detection matters
Transition guards (NEW.status = 'X' AND OLD.status != 'X') prevent duplicate firing on already-terminal rows
COALESCE on rejection_reason prevents NOT NULL violations if HR forgets to set the reason
RETURN NEW is required syntactically even for AFTER triggers where the return value is ignored