Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/migration/1732106699497-InitMigration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export class InitMigration1732106699497 implements MigrationInterface {

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TYPE "public"."evaluation_evaluationstatus_enum" AS ENUM('approved', 'rejected')`);
await queryRunner.query(`CREATE TYPE "public"."evaluation_evaluatortype_enum" AS ENUM('human', 'llm_gpt3')`);
await queryRunner.query(`CREATE TYPE "public"."evaluation_answer_answer_enum" AS ENUM('yes', 'no', 'uncertain')`);
await queryRunner.query(`CREATE TABLE "evaluation" ("id" SERIAL NOT NULL, "evaluator" character varying(42) NOT NULL, "evaluatorType" "public"."evaluation_evaluatortype_enum" NOT NULL, "summary" character varying NOT NULL, "evaluatorScore" integer NOT NULL, "evaluationStatus" "public"."evaluation_evaluationstatus_enum" NOT NULL, "metadataCid" character varying NOT NULL, "applicationId" integer NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "lastUpdatedAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "UQ_566857ce7db15aa0fb1930b4cdf" UNIQUE ("evaluator", "applicationId"), CONSTRAINT "PK_b72edd439b9db736f55b584fa54" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE TABLE "evaluation_answer" ("id" SERIAL NOT NULL, "answer" "public"."evaluation_answer_answer_enum" NOT NULL, "evaluationId" integer NOT NULL, "evaluationQuestionId" integer NOT NULL, CONSTRAINT "UQ_5d5571491f885c88023b5f56366" UNIQUE ("evaluationId", "evaluationQuestionId"), CONSTRAINT "PK_26adcf2e8e65214d2558b8f6910" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE TABLE "evaluation_question" ("id" SERIAL NOT NULL, "questionIndex" integer NOT NULL, "question" character varying NOT NULL, "poolId" integer NOT NULL, CONSTRAINT "UQ_bd9653bd57844a98c0863a0a5b8" UNIQUE ("poolId", "questionIndex"), CONSTRAINT "PK_6ecc0e6614b9c4bc65c6de2c021" PRIMARY KEY ("id"))`);
Expand Down Expand Up @@ -33,6 +35,8 @@ export class InitMigration1732106699497 implements MigrationInterface {
await queryRunner.query(`DROP TABLE "evaluation_answer"`);
await queryRunner.query(`DROP TABLE "evaluation"`);
await queryRunner.query(`DROP TYPE "public"."evaluation_evaluationstatus_enum"`);
await queryRunner.query(`DROP TYPE "public"."evaluation_evaluatortype_enum"`);
await queryRunner.query(`DROP TYPE "public"."evaluation_answer_answer_enum"`);
}

}
18 changes: 10 additions & 8 deletions src/migration/1738025911271-Add-Indexes.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
import { type MigrationInterface, type QueryRunner } from "typeorm";

export class AddPerformanceIndexes1234567890123 implements MigrationInterface {
export class AddIndexes1738025911271 implements MigrationInterface {
name = 'AddIndexes1738025911271'

public async up(queryRunner: QueryRunner): Promise<void> {
// Indexes for Pool lookups
await queryRunner.query(`
CREATE INDEX IF NOT EXISTS idx_pool_chain_allo_pool
ON pool(chain_id, allo_pool_id);
ON "pool"("chainId", "alloPoolId");
`);

// Indexes for Application lookups
await queryRunner.query(`
CREATE INDEX IF NOT EXISTS idx_application_pool_chain
ON application(pool_id, chain_id);
ON "application"("poolId", "chainId");

CREATE INDEX IF NOT EXISTS idx_application_allo_id
ON application(allo_application_id);
ON "application"("alloApplicationId");
`);

// Indexes for Evaluation lookups
await queryRunner.query(`
CREATE INDEX IF NOT EXISTS idx_evaluation_application
ON evaluation(application_id);
ON "evaluation"("applicationId");

CREATE INDEX IF NOT EXISTS idx_evaluation_evaluator
ON evaluation(evaluator, evaluator_type);
ON "evaluation"("evaluator", "evaluatorType");

CREATE INDEX IF NOT EXISTS idx_evaluation_status
ON evaluation(evaluation_status);
ON "evaluation"("evaluationStatus");
`);

// Indexes for EvaluationQuestion lookups
await queryRunner.query(`
CREATE INDEX IF NOT EXISTS idx_eval_question_pool
ON evaluation_question(pool_id, question_index);
ON "evaluation_question"("poolId", "questionIndex");
`);
}

Expand Down