Skip to content

refactor: remove unused schema change chat entities migration#1813

Merged
Artuomka merged 1 commit into
mainfrom
backend_migration_fix
Jun 1, 2026
Merged

refactor: remove unused schema change chat entities migration#1813
Artuomka merged 1 commit into
mainfrom
backend_migration_fix

Conversation

@Artuomka

@Artuomka Artuomka commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Chores
    • Database schema updated with new tables and relationships supporting schema change chat conversations, message storage, and links between user accounts and database connections.
    • Schema change records enhanced with AI auto-fix operation tracking, including columns for applied status, original SQL statements (forward and rollback), and error information.

Copilot AI review requested due to automatic review settings June 1, 2026 09:58
@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e5c77149-d67e-43e2-93e9-a8d99d56e0cd

📥 Commits

Reviewing files that changed from the base of the PR and between 9c031e4 and 14da716.

📒 Files selected for processing (2)
  • backend/src/migrations/1778767036234-AddSchemaChangeChatEntities.ts
  • backend/src/migrations/1779975103808-AddAiAutoFixColumnsToTableSchemaChange.ts
💤 Files with no reviewable changes (1)
  • backend/src/migrations/1779975103808-AddAiAutoFixColumnsToTableSchemaChange.ts

📝 Walkthrough

Walkthrough

Two TypeORM migrations establish schema-change chat infrastructure and AI auto-fix tracking. The first migration creates schema_change_chat and schema_change_chat_message tables with appropriate relationships and a message role enum, while removing response_id from ai_chat_message. The second migration adds four columns to table_schema_change to track auto-fix application status and preserve original SQL/error context.

Changes

Database schema migrations for AI-assisted schema changes

Layer / File(s) Summary
Schema change chat entities and relationships
backend/src/migrations/1778767036234-AddSchemaChangeChatEntities.ts
Creates schema_change_chat and schema_change_chat_message tables with schema_change_chat_message_role_enum, establishes foreign keys to user and connection tables, and removes response_id from ai_chat_message. Down method reverses all operations.
AI auto-fix tracking columns
backend/src/migrations/1779975103808-AddAiAutoFixColumnsToTableSchemaChange.ts
Adds aiAutoFixApplied boolean, aiAutoFixOriginalForwardSql, aiAutoFixOriginalRollbackSql, and aiAutoFixOriginalError columns to table_schema_change table. Down method drops these four columns only.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • rocket-admin/rocketadmin#1770: Creates repositories and use-cases that depend on the schema_change_chat and schema_change_chat_message tables introduced in this migration.

Suggested reviewers

  • lyubov-voloshko

Poem

🐰 A rabbit hops through schema land,
Chat tables bloom, as migrations planned,
Auto-fix columns track the way,
When AI helps to save the day!

🚥 Pre-merge checks | ✅ 4 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title states the change is a refactor to remove an unused migration, but the raw summary shows the migration file was actually added (not removed), with +39/-0 lines. Clarify the title to accurately reflect the actual changes—either the migration was added (not removed), or verify if the intended changes match the PR objectives.
Security Check ⚠️ Warning Migrations expose sensitive SQL and database error details via API responses (aiAutoFixOriginalForwardSql/Sql/Error fields), violating OWASP secure error handling rules. Remove sensitive aiAutoFixOriginal fields from API DTOs, encrypt them, or restrict access to prevent unauthorized exposure of database schema/implementation details.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch backend_migration_fix

Warning

Review ran into problems

🔥 Problems

Stopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a @coderabbit review after the pipeline has finished.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot requested a review from lyubov-voloshko June 1, 2026 09:59

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 refactors TypeORM migrations by moving the schema_change_chat / schema_change_chat_message schema creation (and related ai_chat_message.response_id drop) out of the AddAiAutoFixColumnsToTableSchemaChange migration into a dedicated migration, leaving the AI auto-fix column additions isolated.

Changes:

  • Removed schema-change chat DDL (tables, enum, FKs) and ai_chat_message.response_id drop from 1779975103808, leaving only table_schema_change AI auto-fix columns.
  • Added a new migration 1778767036234 to create schema-change chat tables/type and drop ai_chat_message.response_id.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
backend/src/migrations/1779975103808-AddAiAutoFixColumnsToTableSchemaChange.ts Strips chat-related DDL from the migration, leaving only AI auto-fix columns on table_schema_change.
backend/src/migrations/1778767036234-AddSchemaChangeChatEntities.ts Introduces a new migration that creates schema-change chat tables/type and drops ai_chat_message.response_id.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 6 to 11
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TYPE "public"."schema_change_chat_message_role_enum" AS ENUM('user', 'ai', 'system')`,
);
await queryRunner.query(
`CREATE TABLE "schema_change_chat_message" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "message" text, "role" "public"."schema_change_chat_message_role_enum", "batch_id" uuid, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "updated_at" TIMESTAMP DEFAULT now(), "chat_id" uuid NOT NULL, CONSTRAINT "PK_5984cdb248fa9c2f55f5a19022c" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE TABLE "schema_change_chat" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "name" character varying, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "updated_at" TIMESTAMP DEFAULT now(), "user_id" uuid NOT NULL, "connection_id" character varying(38) NOT NULL, "last_batch_id" uuid, CONSTRAINT "PK_60082e3e240c265fc043290381d" PRIMARY KEY ("id"))`,
);
await queryRunner.query(`ALTER TABLE "ai_chat_message" DROP COLUMN "response_id"`);
await queryRunner.query(`ALTER TABLE "table_schema_change" ADD "aiAutoFixApplied" boolean NOT NULL DEFAULT false`);
await queryRunner.query(`ALTER TABLE "table_schema_change" ADD "aiAutoFixOriginalForwardSql" text`);
await queryRunner.query(`ALTER TABLE "table_schema_change" ADD "aiAutoFixOriginalRollbackSql" text`);
await queryRunner.query(`ALTER TABLE "table_schema_change" ADD "aiAutoFixOriginalError" text`);
await queryRunner.query(
`ALTER TABLE "schema_change_chat_message" ADD CONSTRAINT "FK_32825f4780664738f60fa75cd50" FOREIGN KEY ("chat_id") REFERENCES "schema_change_chat"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
);
await queryRunner.query(
`ALTER TABLE "schema_change_chat" ADD CONSTRAINT "FK_4dbf7dad457505747189fb98d7e" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
);
await queryRunner.query(
`ALTER TABLE "schema_change_chat" ADD CONSTRAINT "FK_9f9acf0578fcf239576640d7b7b" FOREIGN KEY ("connection_id") REFERENCES "connection"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
);
}
Comment on lines +6 to +16
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TABLE "schema_change_chat" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "name" character varying, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "updated_at" TIMESTAMP DEFAULT now(), "user_id" uuid NOT NULL, "connection_id" character varying(38) NOT NULL, "last_batch_id" uuid, CONSTRAINT "PK_60082e3e240c265fc043290381d" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE TYPE "public"."schema_change_chat_message_role_enum" AS ENUM('user', 'ai', 'system')`,
);
await queryRunner.query(
`CREATE TABLE "schema_change_chat_message" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "message" text, "role" "public"."schema_change_chat_message_role_enum", "batch_id" uuid, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "updated_at" TIMESTAMP DEFAULT now(), "chat_id" uuid NOT NULL, CONSTRAINT "PK_5984cdb248fa9c2f55f5a19022c" PRIMARY KEY ("id"))`,
);
await queryRunner.query(`ALTER TABLE "ai_chat_message" DROP COLUMN "response_id"`);
Comment on lines +14 to +17
`CREATE TABLE "schema_change_chat_message" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "message" text, "role" "public"."schema_change_chat_message_role_enum", "batch_id" uuid, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "updated_at" TIMESTAMP DEFAULT now(), "chat_id" uuid NOT NULL, CONSTRAINT "PK_5984cdb248fa9c2f55f5a19022c" PRIMARY KEY ("id"))`,
);
await queryRunner.query(`ALTER TABLE "ai_chat_message" DROP COLUMN "response_id"`);
await queryRunner.query(
@Artuomka Artuomka merged commit bc377bb into main Jun 1, 2026
38 of 46 checks passed
@Artuomka Artuomka deleted the backend_migration_fix branch June 1, 2026 11:32
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