chore(db): add database migration service to docker-compose#301
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the database management strategy by integrating TypeORM for schema migrations. This change ensures that database schema updates are version-controlled, repeatable, and automatically applied when the application starts within a Dockerized environment, improving consistency and reducing manual intervention for database setup and evolution. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a database migration system using TypeORM, which is a significant improvement for managing database schema changes. A dedicated migration service has been added to docker-compose.yml to ensure migrations are applied before the application starts. The database configuration has been refactored to support this new setup. My review has identified a critical issue in the initial migration file that will prevent it from running successfully. Please see the specific comment for details.
| await queryRunner.query(`CREATE INDEX "IDX_27118f1a1f2a0b32462665b591" ON "http_responses" ("assetServiceId") `); | ||
| await queryRunner.query(`CREATE TABLE "ports" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "ports" integer array NOT NULL, "assetId" character varying, "jobHistoryId" uuid, CONSTRAINT "PK_291c9f372b1ce97c885e96f5ff4" PRIMARY KEY ("id"))`); | ||
| await queryRunner.query(`CREATE TABLE "vulnerability_dismissals" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "vulnerabilityId" uuid NOT NULL, "userId" uuid NOT NULL, "reason" character varying NOT NULL, "comment" character varying, CONSTRAINT "UQ_ba00c6117325d322aa2b3683b23" UNIQUE ("vulnerabilityId"), CONSTRAINT "REL_ba00c6117325d322aa2b3683b2" UNIQUE ("vulnerabilityId"), CONSTRAINT "PK_40a07ee5c602766acec8bb4a3af" PRIMARY KEY ("id"))`); | ||
| await queryRunner.query(`CREATE TABLE "vulnerabilities" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "name" character varying NOT NULL, "description" character varying, "synopsis" character varying, "severity" character varying NOT NULL DEFAULT 'info', "tags" text array, "references" text array, "authors" text array, "affectedUrl" character varying, "ipAddress" character varying, "host" character varying, "ports" text array, "cvssMetric" character varying, "cvssScore" double precision, "epssScore" double precision, "vprScore" double precision, "cveId" text array, "bidId" text array, "cweId" text array, "ceaId" text array, "iava" text array, "cveUrl" text, "cweUrl" text, "solution" text, "extractorName" character varying, "extractedResults" text array, "publicationDate" TIMESTAMP WITH TIME ZONE, "modificationDate" TIMESTAMP WITH TIME ZONE, "filePath" character varying, "jobHistoryId" uuid, "isArchived" boolean NOT NULL DEFAULT false, "fingerprint" character varying, "toolId" uuid, "assetId" uuid, CONSTRAINT "UQ_f5a93b9c006858e4b051713eac2" UNIQUE ("fingerprint"), CONSTRAINT "UQ_f5a93b9c006858e4b051713eac2" UNIQUE ("fingerprint"), CONSTRAINT "PK_ee96a1a8d70c431bc2d86485502" PRIMARY KEY ("id"))`); |
There was a problem hiding this comment.
The CREATE TABLE "vulnerabilities" statement contains a duplicate unique constraint on the fingerprint column. This will cause a SQL error and fail the migration. Please remove the duplicate constraint.
| await queryRunner.query(`CREATE TABLE "vulnerabilities" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "name" character varying NOT NULL, "description" character varying, "synopsis" character varying, "severity" character varying NOT NULL DEFAULT 'info', "tags" text array, "references" text array, "authors" text array, "affectedUrl" character varying, "ipAddress" character varying, "host" character varying, "ports" text array, "cvssMetric" character varying, "cvssScore" double precision, "epssScore" double precision, "vprScore" double precision, "cveId" text array, "bidId" text array, "cweId" text array, "ceaId" text array, "iava" text array, "cveUrl" text, "cweUrl" text, "solution" text, "extractorName" character varying, "extractedResults" text array, "publicationDate" TIMESTAMP WITH TIME ZONE, "modificationDate" TIMESTAMP WITH TIME ZONE, "filePath" character varying, "jobHistoryId" uuid, "isArchived" boolean NOT NULL DEFAULT false, "fingerprint" character varying, "toolId" uuid, "assetId" uuid, CONSTRAINT "UQ_f5a93b9c006858e4b051713eac2" UNIQUE ("fingerprint"), CONSTRAINT "UQ_f5a93b9c006858e4b051713eac2" UNIQUE ("fingerprint"), CONSTRAINT "PK_ee96a1a8d70c431bc2d86485502" PRIMARY KEY ("id"))`); | |
| await queryRunner.query(`CREATE TABLE "vulnerabilities" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "name" character varying NOT NULL, "description" character varying, "synopsis" character varying, "severity" character varying NOT NULL DEFAULT 'info', "tags" text array, "references" text array, "authors" text array, "affectedUrl" character varying, "ipAddress" character varying, "host" character varying, "ports" text array, "cvssMetric" character varying, "cvssScore" double precision, "epssScore" double precision, "vprScore" double precision, "cveId" text array, "bidId" text array, "cweId" text array, "ceaId" text array, "iava" text array, "cveUrl" text, "cweUrl" text, "solution" text, "extractorName" character varying, "extractedResults" text array, "publicationDate" TIMESTAMP WITH TIME ZONE, "modificationDate" TIMESTAMP WITH TIME ZONE, "filePath" character varying, "jobHistoryId" uuid, "isArchived" boolean NOT NULL DEFAULT false, "fingerprint" character varying, "toolId" uuid, "assetId" uuid, CONSTRAINT "UQ_f5a93b9c006858e4b051713eac2" UNIQUE ("fingerprint"), CONSTRAINT "PK_ee96a1a8d70c431bc2d86485502" PRIMARY KEY ("id"))`); |
No description provided.