Backend ai table settings fix#1540
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds timestamp tracking (created_at and updated_at) to three database entities (personal_table_settings, tableSettings, and table_widget) and improves AI-driven table settings generation with better error handling and batch processing capabilities.
Changes:
- Added created_at and updated_at columns to personal_table_settings, tableSettings, and table_widget entities via migration
- Implemented batch processing (10 tables at a time) in AI service with fallback to individual processing on errors
- Enhanced error handling in shared jobs service to gracefully handle table information retrieval failures
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| backend/src/migrations/1769610545842-AddTimeStampColumnsIntoSettingsAndWidgetsEntities.ts | Migration to add timestamp columns with up/down methods |
| backend/src/entities/widget/table-widget.entity.ts | Added CreateDateColumn and UpdateDateColumn decorators to table widget entity |
| backend/src/entities/table-settings/personal-table-settings/personal-table-settings.entity.ts | Added CreateDateColumn and UpdateDateColumn decorators to personal table settings entity |
| backend/src/entities/table-settings/common-table-settings/table-settings.entity.ts | Added CreateDateColumn and UpdateDateColumn decorators to common table settings entity |
| backend/src/entities/shared-jobs/shared-jobs.service.ts | Added error handling for table information retrieval and additional logging |
| backend/src/entities/ai/ai.service.ts | Refactored to process tables in batches with individual fallback on errors |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| await queryRunner.query(`ALTER TABLE "personal_table_settings" ADD "updated_at" TIMESTAMP DEFAULT now()`); | ||
| await queryRunner.query(`ALTER TABLE "tableSettings" ADD "created_at" TIMESTAMP NOT NULL DEFAULT now()`); | ||
| await queryRunner.query(`ALTER TABLE "tableSettings" ADD "updated_at" TIMESTAMP DEFAULT now()`); | ||
| await queryRunner.query(`ALTER TABLE "table_widget" ADD "created_at" TIMESTAMP NOT NULL DEFAULT now()`); | ||
| await queryRunner.query(`ALTER TABLE "table_widget" ADD "updated_at" TIMESTAMP DEFAULT now()`); |
There was a problem hiding this comment.
The migration sets DEFAULT now() for the updated_at column, but the entity's @UpdateDateColumn decorator is configured with nullable: true and default: null. This creates a mismatch between the database schema and the entity definition. The updated_at field should not have a default value on insert - it should only be set when a record is updated. Remove DEFAULT now() from this migration query to match the entity definition.
| await queryRunner.query(`ALTER TABLE "personal_table_settings" ADD "updated_at" TIMESTAMP DEFAULT now()`); | |
| await queryRunner.query(`ALTER TABLE "tableSettings" ADD "created_at" TIMESTAMP NOT NULL DEFAULT now()`); | |
| await queryRunner.query(`ALTER TABLE "tableSettings" ADD "updated_at" TIMESTAMP DEFAULT now()`); | |
| await queryRunner.query(`ALTER TABLE "table_widget" ADD "created_at" TIMESTAMP NOT NULL DEFAULT now()`); | |
| await queryRunner.query(`ALTER TABLE "table_widget" ADD "updated_at" TIMESTAMP DEFAULT now()`); | |
| await queryRunner.query(`ALTER TABLE "personal_table_settings" ADD "updated_at" TIMESTAMP`); | |
| await queryRunner.query(`ALTER TABLE "tableSettings" ADD "created_at" TIMESTAMP NOT NULL DEFAULT now()`); | |
| await queryRunner.query(`ALTER TABLE "tableSettings" ADD "updated_at" TIMESTAMP`); | |
| await queryRunner.query(`ALTER TABLE "table_widget" ADD "created_at" TIMESTAMP NOT NULL DEFAULT now()`); | |
| await queryRunner.query(`ALTER TABLE "table_widget" ADD "updated_at" TIMESTAMP`); |
| await queryRunner.query(`ALTER TABLE "personal_table_settings" ADD "updated_at" TIMESTAMP DEFAULT now()`); | ||
| await queryRunner.query(`ALTER TABLE "tableSettings" ADD "created_at" TIMESTAMP NOT NULL DEFAULT now()`); | ||
| await queryRunner.query(`ALTER TABLE "tableSettings" ADD "updated_at" TIMESTAMP DEFAULT now()`); | ||
| await queryRunner.query(`ALTER TABLE "table_widget" ADD "created_at" TIMESTAMP NOT NULL DEFAULT now()`); | ||
| await queryRunner.query(`ALTER TABLE "table_widget" ADD "updated_at" TIMESTAMP DEFAULT now()`); |
There was a problem hiding this comment.
The migration sets DEFAULT now() for the updated_at column, but the entity's @UpdateDateColumn decorator is configured with nullable: true and default: null. This creates a mismatch between the database schema and the entity definition. The updated_at field should not have a default value on insert - it should only be set when a record is updated. Remove DEFAULT now() from this migration query to match the entity definition.
| await queryRunner.query(`ALTER TABLE "personal_table_settings" ADD "updated_at" TIMESTAMP DEFAULT now()`); | |
| await queryRunner.query(`ALTER TABLE "tableSettings" ADD "created_at" TIMESTAMP NOT NULL DEFAULT now()`); | |
| await queryRunner.query(`ALTER TABLE "tableSettings" ADD "updated_at" TIMESTAMP DEFAULT now()`); | |
| await queryRunner.query(`ALTER TABLE "table_widget" ADD "created_at" TIMESTAMP NOT NULL DEFAULT now()`); | |
| await queryRunner.query(`ALTER TABLE "table_widget" ADD "updated_at" TIMESTAMP DEFAULT now()`); | |
| await queryRunner.query(`ALTER TABLE "personal_table_settings" ADD "updated_at" TIMESTAMP`); | |
| await queryRunner.query(`ALTER TABLE "tableSettings" ADD "created_at" TIMESTAMP NOT NULL DEFAULT now()`); | |
| await queryRunner.query(`ALTER TABLE "tableSettings" ADD "updated_at" TIMESTAMP`); | |
| await queryRunner.query(`ALTER TABLE "table_widget" ADD "created_at" TIMESTAMP NOT NULL DEFAULT now()`); | |
| await queryRunner.query(`ALTER TABLE "table_widget" ADD "updated_at" TIMESTAMP`); |
| await queryRunner.query(`ALTER TABLE "personal_table_settings" ADD "updated_at" TIMESTAMP DEFAULT now()`); | ||
| await queryRunner.query(`ALTER TABLE "tableSettings" ADD "created_at" TIMESTAMP NOT NULL DEFAULT now()`); | ||
| await queryRunner.query(`ALTER TABLE "tableSettings" ADD "updated_at" TIMESTAMP DEFAULT now()`); | ||
| await queryRunner.query(`ALTER TABLE "table_widget" ADD "created_at" TIMESTAMP NOT NULL DEFAULT now()`); | ||
| await queryRunner.query(`ALTER TABLE "table_widget" ADD "updated_at" TIMESTAMP DEFAULT now()`); |
There was a problem hiding this comment.
The migration sets DEFAULT now() for the updated_at column, but the entity's @UpdateDateColumn decorator is configured with nullable: true and default: null. This creates a mismatch between the database schema and the entity definition. The updated_at field should not have a default value on insert - it should only be set when a record is updated. Remove DEFAULT now() from this migration query to match the entity definition.
| await queryRunner.query(`ALTER TABLE "personal_table_settings" ADD "updated_at" TIMESTAMP DEFAULT now()`); | |
| await queryRunner.query(`ALTER TABLE "tableSettings" ADD "created_at" TIMESTAMP NOT NULL DEFAULT now()`); | |
| await queryRunner.query(`ALTER TABLE "tableSettings" ADD "updated_at" TIMESTAMP DEFAULT now()`); | |
| await queryRunner.query(`ALTER TABLE "table_widget" ADD "created_at" TIMESTAMP NOT NULL DEFAULT now()`); | |
| await queryRunner.query(`ALTER TABLE "table_widget" ADD "updated_at" TIMESTAMP DEFAULT now()`); | |
| await queryRunner.query(`ALTER TABLE "personal_table_settings" ADD "updated_at" TIMESTAMP`); | |
| await queryRunner.query(`ALTER TABLE "tableSettings" ADD "created_at" TIMESTAMP NOT NULL DEFAULT now()`); | |
| await queryRunner.query(`ALTER TABLE "tableSettings" ADD "updated_at" TIMESTAMP`); | |
| await queryRunner.query(`ALTER TABLE "table_widget" ADD "created_at" TIMESTAMP NOT NULL DEFAULT now()`); | |
| await queryRunner.query(`ALTER TABLE "table_widget" ADD "updated_at" TIMESTAMP`); |
No description provided.