Status: PENDING - To be completed before migration deploymentDocumentation Index
Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
Use this file to discover all available pages before exploring further.
Created: 2026-02-08
Target Date: 2026-02-15
Migration 1: hr_references Token Hashing ✓ PREP COMPLETE
Code Changes Needed
-
Edge Function:
supabase/functions/hr-reference-submit/index.ts- Implement
hashToken(token: string, salt: Uint8Array)function - Implement
validateToken(presentedToken: string, storedHash: string)function - Generate 16-byte salt for new tokens:
crypto.getRandomValues(new Uint8Array(16)) - Store
Base64(salt + hash)inaccess_token_hashcolumn - Maintain backward compatibility: validate plaintext tokens during transition
- Implement
-
Hook:
src/cores/hr/hooks/useReferences.ts- Update token generation to use edge function for hashing
- Log all token validations for audit
-
Tests:
tests/unit/hr/useReferences.test.ts- Test token hashing with various inputs
- Test backward compatibility with plaintext tokens
- Test salt uniqueness per token
Validation Tests
Estimated Effort
- Development: 2-3 hours
- Testing: 1-2 hours
- Validation: 1 hour
Migration 2: hr_candidate_portal_sessions Organization Isolation ✓ PREP COMPLETE
Code Changes Needed
-
Hook:
src/cores/hr/hooks/useCandidatePortalSession.ts- Update
createSession()to requireorganizationIdparameter - Pass
organization_idto INSERT queries - Update
fetchSession()to includeorganization_idin response
- Update
-
Components: Anywhere creating portal sessions
- Search for
createSession(candidateId)calls - Update to
createSession(candidateId, organizationId) - Extract organization from auth context or route params
- Search for
-
Edge Functions: Any portal session creation
- Validate
organization_idfrom JWT claims - Ensure sessions cannot be created for other organizations
- Validate
-
RLS Policies: Verify in Supabase dashboard
- Test org-scoped isolation
- Verify cross-org access is blocked
Affected Components to Search
Validation Tests
Estimated Effort
- Development: 1-2 hours
- Testing: 1-2 hours
- Validation: 1 hour
Migration 3: hr_job_board_integrations Credential Encryption ✓ PREP COMPLETE
Code Changes Needed
-
Hook:
src/cores/hr/hooks/useJobBoardIntegrations.ts- Update SELECT queries to fetch
credential:pf_credentials!credential_id(*) - Add fallback logic to read from plaintext columns during transition
- Create new records with
credential_idinstead of plaintext fields - Add migration helper to move existing credentials
- Update SELECT queries to fetch
-
Edge Functions: Any that use job board credentials
- Fetch credentials from
pf_credentialstable - Decrypt via dedicated decryption function
- Remove hardcoded plaintext credential usage
- Fetch credentials from
-
Migration Script: Create credential migration tool
- Script:
scripts/migrate-job-board-credentials.ts - Verify all plaintext credentials moved to
pf_credentials - Log migrations in
pf_credential_migrationstable
- Script:
-
Tests: Update to use encrypted credentials
- Mock
pf_credentialstable instead of plaintext columns - Test credential decryption in edge functions
- Mock
Transition Support Matrix
| Scenario | Before Migration | After Migration | Fallback |
|---|---|---|---|
| New integration | plaintext | credential_id | N/A |
| Old integration (no change) | plaintext | credential_id OR plaintext | plaintext |
| Updated integration | plaintext | credential_id | plaintext if missing |
Validation Tests
Estimated Effort
- Development: 3-4 hours
- Testing: 2-3 hours
- Validation: 1-2 hours
- Data migration: 0.5-1 hour
Database Type Updates
After all migrations are applied (by DevOps), run:src/cores/hr/hooks/useReferences.tssrc/cores/hr/hooks/useCandidatePortalSession.tssrc/cores/hr/hooks/useJobBoardIntegrations.ts- Components using these hooks
Summary: Code Readiness Status
| Component | Status | Est. Hours | Priority |
|---|---|---|---|
| Token Hashing (Migration 1) | PENDING | 4-5 hrs | HIGH |
| Organization Isolation (Migration 2) | PENDING | 3-4 hrs | HIGH |
| Credential Encryption (Migration 3) | PENDING | 6-7 hrs | MEDIUM |
| Type Updates | PENDING | 1-2 hrs | HIGH |
| TOTAL | 14-18 hrs |
Timeline Recommendation
- Feb 8-10: Implement code changes (14-18 hours)
- Feb 10-12: Review & test (4-6 hours)
- Feb 12-14: Staging run (2-3 hours)
- Feb 15: Production migration (1-2 hours with on-call)
Sign-Off
- All code changes reviewed by tech lead
- All tests passing (unit, RLS, E2E)
- Staging migration successful
- Team briefed on rollback procedures
- On-call schedule confirmed for migration night