Skip to content

Conversation

@andrewsignori-aot
Copy link
Collaborator

PR to support the initial analisys for the new DB structure.

@andrewsignori-aot andrewsignori-aot self-assigned this Jan 20, 2026
@andrewsignori-aot andrewsignori-aot added the DB DB migration involved label Jan 20, 2026
@andrewsignori-aot andrewsignori-aot changed the title #5594 - Analysis: new unified data path for appeals and forms + non punitive (Initial draft DB migrations) #5594 - Analysis: new unified data path for appeals and forms + non punitive (DB migrations) Jan 21, 2026
@github-actions
Copy link

Backend Unit Tests Coverage Report

Totals Coverage
Statements: 20.29% ( 4345 / 21418 )
Methods: 9.79% ( 256 / 2615 )
Lines: 24.43% ( 3725 / 15245 )
Branches: 10.23% ( 364 / 3558 )

@github-actions
Copy link

E2E SIMS API Coverage Report

Totals Coverage
Statements: 77.19% ( 8808 / 11411 )
Methods: 76.66% ( 1041 / 1358 )
Lines: 81.21% ( 6397 / 7877 )
Branches: 62.96% ( 1370 / 2176 )

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces the database schema foundation for a unified approach to handling appeals and form submissions. It creates new tables and enums to support a flexible form submission system where multiple forms can be grouped together as a bundle or submitted independently.

Changes:

  • Added four new PostgreSQL enum types for form categorization and submission workflows
  • Created two new database tables (form_submissions and form_submission_items) to store submitted forms and their assessment status
  • Extended the dynamic_form_configurations table with form category and grouping type columns

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
sources/packages/backend/libs/sims-db/src/entities/index.ts Exports new enum types and FormSubmission model (missing FormSubmissionItem and FormSubmissionDecisionStatus exports)
sources/packages/backend/libs/sims-db/src/entities/form-submission.model.ts Defines FormSubmission entity to track form submission bundles
sources/packages/backend/libs/sims-db/src/entities/form-submission-item.model.ts Defines FormSubmissionItem entity for individual forms within a submission
sources/packages/backend/libs/sims-db/src/entities/form-submission-status.type.ts Enum for submission-level status (Pending, Completed, Declined)
sources/packages/backend/libs/sims-db/src/entities/form-submission-grouping.type.ts Enum defining how forms are grouped (Application bundle vs Student standalone)
sources/packages/backend/libs/sims-db/src/entities/form-submission-decision-status.type.ts Enum for item-level decision status (Pending, Approved, Declined)
sources/packages/backend/libs/sims-db/src/entities/form-category.type.ts Enum for form categories (Student appeal, Student form, System)
sources/packages/backend/libs/sims-db/src/entities/dynamic-form-configuration.model.ts Adds formCategory and formSubmissionGroupingType properties to support new workflow
sources/packages/backend/libs/sims-db/src/constant.ts Adds table name constants for new tables
sources/packages/backend/apps/db-migrations/src/sql/Types/Create-form-submission-related-types.sql Creates PostgreSQL enum types for form submission workflow
sources/packages/backend/apps/db-migrations/src/sql/Types/Rollback-create-form-submission-related-types.sql Rollback script for enum types
sources/packages/backend/apps/db-migrations/src/sql/FormSubmissions/Create-form-submissions-table.sql Creates form_submissions table with constraints
sources/packages/backend/apps/db-migrations/src/sql/FormSubmissions/Rollback-create-form-submissions-table.sql Rollback script for form_submissions table
sources/packages/backend/apps/db-migrations/src/sql/FormSubmissionItems/Create-form-submission-items-table.sql Creates form_submission_items table
sources/packages/backend/apps/db-migrations/src/sql/FormSubmissionItems/Rollback-create-form-submission-items-table.sql Rollback script for form_submission_items table
sources/packages/backend/apps/db-migrations/src/sql/DynamicFormConfigurations/Add-form-submission-grouping-type-column.sql Adds new columns and seed data to dynamic_form_configurations
sources/packages/backend/apps/db-migrations/src/sql/DynamicFormConfigurations/Rollback-add-form-submission-grouping-type-column.sql Rollback script for dynamic_form_configurations changes
sources/packages/backend/apps/db-migrations/src/migrations/1768863388343-CreateFormSubmissionRelatedTypes.ts TypeScript migration wrapper for creating enum types
sources/packages/backend/apps/db-migrations/src/migrations/1768863415862-CreateFormSubmissionsTable.ts TypeScript migration wrapper for creating form_submissions table
sources/packages/backend/apps/db-migrations/src/migrations/1768863437173-CreateFormSubmissionItemsTable.ts TypeScript migration wrapper for creating form_submission_items table
sources/packages/backend/apps/db-migrations/src/migrations/1768863470903-DynamicFormConfigurationsAddFormSubmissionGroupingTypeColumn.ts TypeScript migration wrapper for extending dynamic_form_configurations
sims.code-workspace Formatting updates (adding trailing commas for consistency)

name: "form_category",
type: "enum",
enum: FormCategory,
enumName: "FormCategory",
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

The enumName should reference the actual PostgreSQL enum type name created in the migration. The SQL creates 'form_category_types' (see Create-form-submission-related-types.sql line 1 and this column uses it on Create-form-submissions-table.sql line 6), but this specifies 'FormCategory'. This mismatch will cause runtime errors. Change enumName to 'form_category_types'.

Suggested change
enumName: "FormCategory",
enumName: "form_category_types",

Copilot uses AI. Check for mistakes.
name: "submission_status",
type: "enum",
enum: FormSubmissionStatus,
enumName: "FormSubmissionStatus",
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

The enumName should reference the actual PostgreSQL enum type name created in the migration. The SQL creates 'form_submission_status' (see Create-form-submission-related-types.sql line 16 and this column uses it on Create-form-submissions-table.sql line 8), but this specifies 'FormSubmissionStatus'. This mismatch will cause runtime errors. Change enumName to 'form_submission_status'.

Suggested change
enumName: "FormSubmissionStatus",
enumName: "form_submission_status",

Copilot uses AI. Check for mistakes.
name: "submission_status",
type: "enum",
enum: FormSubmissionDecisionStatus,
enumName: "FormSubmissionDecisionStatus",
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

The enumName should reference the actual PostgreSQL enum type name created in the migration. The SQL creates 'form_submission_decision_status' (see Create-form-submission-related-types.sql line 24 and this column uses it on Create-form-submission-items-table.sql line 6), but this specifies 'FormSubmissionDecisionStatus'. This mismatch will cause runtime errors. Change enumName to 'form_submission_decision_status'.

Suggested change
enumName: "FormSubmissionDecisionStatus",
enumName: "form_submission_decision_status",

Copilot uses AI. Check for mistakes.
name: "form_category",
type: "enum",
enum: FormCategory,
enumName: "FormCategory",
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

The enumName should reference the actual PostgreSQL enum type name created in the migration. The SQL creates 'form_category_types' (see Create-form-submission-related-types.sql line 1 and the Add-form-submission-grouping-type-column.sql uses it on line 4), but this specifies 'FormCategory'. This mismatch will cause runtime errors. Change enumName to 'form_category_types'.

Suggested change
enumName: "FormCategory",
enumName: "form_category_types",

Copilot uses AI. Check for mistakes.
-- Constraints comments.
COMMENT ON CONSTRAINT form_submissions_application_id_constraint ON sims.form_submissions IS 'Ensures application_id is present when submission_grouping_type is application-related.';

COMMENT ON CONSTRAINT form_submissions_assessed_fields_required_constraint ON sims.form_submissions IS 'Requires assessed_date, assessed_by, and assessed_student_note_id when submission_status is not Pending.'; No newline at end of file
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

The constraint comment refers to 'assessed_student_note_id' but the actual column name in the table is 'assessed_note_id'. The comment should reference the correct column name to match the constraint definition on lines 28-38.

Suggested change
COMMENT ON CONSTRAINT form_submissions_assessed_fields_required_constraint ON sims.form_submissions IS 'Requires assessed_date, assessed_by, and assessed_student_note_id when submission_status is not Pending.';
COMMENT ON CONSTRAINT form_submissions_assessed_fields_required_constraint ON sims.form_submissions IS 'Requires assessed_date, assessed_by, and assessed_note_id when submission_status is not Pending.';

Copilot uses AI. Check for mistakes.
name: "submission_grouping_type",
type: "enum",
enum: FormSubmissionGrouping,
enumName: "FormSubmissionGrouping",
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

The enumName should reference the actual PostgreSQL enum type name created in the migration. The SQL creates 'form_submission_grouping_types' (see Create-form-submission-related-types.sql line 9 and this column uses it on Create-form-submissions-table.sql line 7), but this specifies 'FormSubmissionGrouping'. This mismatch will cause runtime errors. Change enumName to 'form_submission_grouping_types'.

Suggested change
enumName: "FormSubmissionGrouping",
enumName: "form_submission_grouping_types",

Copilot uses AI. Check for mistakes.
name: "form_submission_grouping_type",
type: "enum",
enum: FormSubmissionGrouping,
enumName: "FormSubmissionGrouping",
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

The enumName should reference the actual PostgreSQL enum type name created in the migration. The SQL creates 'form_submission_grouping_types' (see Create-form-submission-related-types.sql line 9 and the Add-form-submission-grouping-type-column.sql uses it on line 6), but this specifies 'FormSubmissionGrouping'. This mismatch will cause runtime errors. Change enumName to 'form_submission_grouping_types'.

Suggested change
enumName: "FormSubmissionGrouping",
enumName: "form_submission_grouping_types",

Copilot uses AI. Check for mistakes.
})
formSubmission: FormSubmission;
/**
*Dynamic form configuration used to render and validate this item.
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

Missing space after asterisk at the beginning of the JSDoc comment. The comment should start with a space after the asterisk to follow proper JSDoc formatting conventions.

Copilot generated this review using guidance from repository custom instructions.
COMMENT ON COLUMN sims.form_submission_items.modifier IS 'User ID of the last user who modified the record.';

-- Constraints comments.
COMMENT ON CONSTRAINT form_submission_items_decision_fields_required_constraint ON sims.form_submission_items IS 'Requires decision_date, decision_by, and decision_note_id when submission_status is not pending.'; No newline at end of file
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

The constraint comment incorrectly refers to 'submission_status' but the actual column being checked is 'decision_status'. This is misleading and should reference the correct column name to match the constraint definition on lines 16-26.

Suggested change
COMMENT ON CONSTRAINT form_submission_items_decision_fields_required_constraint ON sims.form_submission_items IS 'Requires decision_date, decision_by, and decision_note_id when submission_status is not pending.';
COMMENT ON CONSTRAINT form_submission_items_decision_fields_required_constraint ON sims.form_submission_items IS 'Requires decision_date, decision_by, and decision_note_id when decision_status is not pending.';

Copilot uses AI. Check for mistakes.
export * from "./form-submission-grouping.type";
export * from "./form-category.type";
export * from "./form-submission-status.type";
export * from "./form-submission.model";
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

The FormSubmissionDecisionStatus enum is not exported from the index.ts file. This enum is used by FormSubmissionItem and should be exported to make it available for use in other parts of the application.

Suggested change
export * from "./form-submission.model";
export * from "./form-submission.model";
export * from "./form-submission-decision-status.type";

Copilot uses AI. Check for mistakes.
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
4.1% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@github-actions
Copy link

E2E Workflow Workers Coverage Report

Totals Coverage
Statements: 75.41% ( 1055 / 1399 )
Methods: 79.31% ( 115 / 145 )
Lines: 78.79% ( 769 / 976 )
Branches: 61.51% ( 171 / 278 )

@github-actions
Copy link

E2E Queue Consumers Coverage Report

Totals Coverage
Statements: 85.68% ( 1616 / 1886 )
Methods: 85% ( 187 / 220 )
Lines: 88.64% ( 1287 / 1452 )
Branches: 66.36% ( 142 / 214 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DB DB migration involved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants