Skip to content

Conversation

@JamesTLopez
Copy link
Contributor

@JamesTLopez JamesTLopez commented Jan 19, 2026

TODO: Once Approved, will generate an updated data-model.png

Special Instructions

Steps on how to apply the dac_id migrations:

# Generate dac_id column with relation but nullable
pnpm drizzle-kit migrate

# 1. Will insert a row into table `dac` with dac_id value from PCGL-TEST-ID
# 2. Will backfill NULL values for existing application with value from .env var PCGL-TEST-ID
# 3. Finally, Alter dac_id column in application to NOT NULL
pnpm run migrate:db:dac-id

Summary

dac_id migration for the applications model table.

Related Issues

Description of Changes

  • Create new PCGL_DACO_ID environment variable
  • Added migration for dac_id into Application table
  • Added migration script:
    • Creates a entry into dac table with PCGL_DACO_ID
    • Backfill application entries with null dac_id with the PCGL_DAC_ID env var
    • Alter application table col dac_id to not null.

Readiness Checklist

  • Self Review
    • I have performed a self review of code
    • I have run the application locally and manually tested the feature
  • PR Format
    • The PR title is properly formatted to match the pattern: #{TicketNumber}: Description of Changes
    • Links are included to all relevant tickets
  • Labels Added
    • Label is added for each package/app that is modified (api, ui, data-model, etc.)
    • Label is added for the type of work done in this PR (feature, fix, chore, documentation)
  • Local Testing
    • Successfully built all packages locally
    • Successfully ran all test suites, all unit and integration tests pass
  • Updated Tests
    • Unit and integration tests have been added that describe the bug that was fixed or the features that were added
  • Documentation
    • All new environment variables added to .env.schema file and documented in the README
    • All changes to server HTTP endpoints have open-api documentation
    • All new functions exported from their module have TSDoc comment documentation

@JamesTLopez JamesTLopez requested review from demariadaniel, joneubank and leoraba and removed request for demariadaniel January 20, 2026 16:53
@JamesTLopez JamesTLopez marked this pull request as ready for review January 20, 2026 16:53
Comment on lines 42 to 48
// Apply backfill with PCGL_DACO_ID
await transaction
.update(applications)
.set({
dac_id: `${dbConfig.PCGL_DACO_ID}`,
})
.where(isNull(applications.dac_id));
Copy link
Contributor

Choose a reason for hiding this comment

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

We need an additional filter here to only select applications that are past the submitted for reivew stage (under review, revisions requested, or approved i think?)

Copy link
Contributor Author

@JamesTLopez JamesTLopez Jan 23, 2026

Choose a reason for hiding this comment

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

I left application state CLOSED out of the backfill as well because technically an applicant can close a application while its still in DRAFT. BUT they can also close it post review stage, so I am unsure whats the more 'correct' option here.

Open to insight

Heres the commit for the update: e7558b1

@JamesTLopez JamesTLopez requested a review from joneubank January 23, 2026 17:02
"dev:server": "tsx watch --clear-screen=false --env-file=.env ./src/main.ts",
"dev:watch": "nx watch --projects=@pcgl-daco/api --includeDependentProjects -- nx run-many -t build \\$NX_PROJECT_NAME --exclude=@pcgl-daco/api",
"dbml": "tsx ./src/db/dbml.ts",
"migrate:dac-id": "tsx --env-file=.env src/scripts/dac-id-migration.ts",
Copy link
Contributor Author

@JamesTLopez JamesTLopez Jan 23, 2026

Choose a reason for hiding this comment

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

naming is hard, open to name suggestions for this script. Or its fine as it is

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