JACoB PR for Issue Add Evaluation Data Storage to Projects Table Using JSONb #140
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.
Summary:
Background
We need to enhance the projects table to store evaluation data for project assessments. This data needs to be persisted in a structured format using a JSONb field, allowing for flexible storage of evaluation metrics and results.
Requirements
Database Changes:
evaluationDataJSONb column to the projects tableTable Updates:
/src/server/db/tables/projects.table.tsto include the new JSONb fieldTRPC Route Enhancement:
Expected Outcome
When implemented, the system will be able to:
The database structure will be updated to accommodate this new data storage requirement without breaking existing functionality or requiring data migration for existing records.
Technical Details
This implementation involves:
@jacob-ai-bot --skip-build
Plan:
Step 1: Create
/src/server/db/migrations/20241018000000_addEvaluationDataToProjects.tsTask: Create migration to add 'evaluationData' JSONb column to 'projects' table
Instructions:
Create a new migration file that adds a nullable JSONb column named 'evaluationData' to the 'projects' table. The column should have a default value of NULL to maintain compatibility with existing records. Follow the existing migration file structure and naming conventions as shown in the codebase (e.g., 'add_settings_to_project.ts').
Exit Criteria:
Applying the new migration adds the 'evaluationData' column to the 'projects' table successfully without errors, and existing data remains intact.
Step 2: Edit
/src/server/db/tables/projects.table.tsTask: Update 'ProjectsTable' schema to include 'evaluationData' field
Instructions:
In the file '/src/server/db/tables/projects.table.ts', update the 'ProjectsTable' class by adding a new column definition for 'evaluationData'. Use 't.json().nullable()' to define the column as a nullable JSON field. Ensure TypeScript types 'Project', 'NewProject', and 'ProjectUpdate' are updated to include the new 'evaluationData' field with appropriate typing.
Exit Criteria:
The 'ProjectsTable' class includes the 'evaluationData' field with correct TypeScript typings, and the project builds without any type errors.
Step 3: Edit
/src/server/api/routers/onboarding.tsTask: Enhance TRPC onboarding router to handle 'evaluationData'
Instructions:
In '/src/server/api/routers/onboarding.ts', modify the TRPC procedures related to project creation and settings update to accept an optional 'evaluationData' field. Update the input schema using Zod to include 'evaluationData' as a nullable field. In the 'saveSettings' mutation and any other relevant procedures, adjust the database operations to save 'evaluationData' to the 'projects' table when it is provided. Ensure that the existing functionality remains unaffected when 'evaluationData' is not included.
Exit Criteria:
The TRPC routes handling project creation and updates can now accept and store 'evaluationData' without disrupting existing workflows. All existing functionalities operate as before, and new projects can include 'evaluationData' in their creation process.