Skip to content

Create Github Actions to automatically sync TypeScript Definitions with Database #96

@Vaibhav978

Description

@Vaibhav978

Is your feature request related to a problem? Please describe.
When the database schema changes, the TypeScript type definitions in each lambda function's db-types.d.ts files become out of sync. This requires manual regeneration using `kysely-codegen.

Currently, we have 4 lambda functions that each need their db-types.d.ts file updated:

  • apps/backend/lambdas/donors/db-types.d.ts
  • apps/backend/lambdas/expenditures/db-types.d.ts
  • apps/backend/lambdas/projects/db-types.d.ts
  • apps/backend/lambdas/users/db-types.d.ts

Describe the solution you'd like
Create a GitHub Action workflow that automatically regenerates database type files whenever the database schema changes. The workflow should:

  1. Trigger on pull requests when database-related files are modified:

    • apps/backend/db/db_setup.sql
    • apps/backend/db/kysely-codegen.config.js
  2. Run kysely-codegen to generate fresh TypeScript types

    • Copy the generated types to each lambda function's db-types.d.ts file
  3. Commit changes automatically

    • Commit the updated type files back to the PR branch
    • Include a clear commit message: chore: auto-regenerate database types from schema changes
    • Co-author with the PR creator (similar to terraform-plan.yml workflow, this is more optional)
  4. Verify that the generated types compile correctly

  • Fail the workflow if type generation fails with clear error messages

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions