Skip to content

Backend ai table settings fix#1540

Merged
Artuomka merged 2 commits into
mainfrom
backend_ai_table_settings_fix
Jan 28, 2026
Merged

Backend ai table settings fix#1540
Artuomka merged 2 commits into
mainfrom
backend_ai_table_settings_fix

Conversation

@Artuomka

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings January 28, 2026 15:43
@Artuomka Artuomka enabled auto-merge January 28, 2026 15:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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.

Comment on lines +8 to +12
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()`);

Copilot AI Jan 28, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
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`);

Copilot uses AI. Check for mistakes.
Comment on lines +8 to +12
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()`);

Copilot AI Jan 28, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
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`);

Copilot uses AI. Check for mistakes.
Comment on lines +8 to +12
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()`);

Copilot AI Jan 28, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
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`);

Copilot uses AI. Check for mistakes.
@Artuomka Artuomka merged commit 6345c2e into main Jan 28, 2026
25 checks passed
@Artuomka Artuomka deleted the backend_ai_table_settings_fix branch January 28, 2026 15:50
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.

2 participants