From f0e272d0f2d5ecd278b8eaf71087f6132d91c4ab Mon Sep 17 00:00:00 2001 From: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com> Date: Tue, 28 Mar 2023 16:53:35 +0200 Subject: [PATCH] feat(server): change clipembedding entity type (#2091) --- .../infra/src/db/entities/smart-info.entity.ts | 5 +---- .../1679901204458-ClipEmbeddingFloat4.ts | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 server/libs/infra/src/db/migrations/1679901204458-ClipEmbeddingFloat4.ts diff --git a/server/libs/infra/src/db/entities/smart-info.entity.ts b/server/libs/infra/src/db/entities/smart-info.entity.ts index 20edfaf43c..cd6b9e1723 100644 --- a/server/libs/infra/src/db/entities/smart-info.entity.ts +++ b/server/libs/infra/src/db/entities/smart-info.entity.ts @@ -17,12 +17,9 @@ export class SmartInfoEntity { objects!: string[] | null; @Column({ - type: 'numeric', + type: 'float4', array: true, nullable: true, - // note: migration generator is broken for numeric[], but these _are_ set in the database - // precision: 20, - // scale: 19, }) clipEmbedding!: number[] | null; } diff --git a/server/libs/infra/src/db/migrations/1679901204458-ClipEmbeddingFloat4.ts b/server/libs/infra/src/db/migrations/1679901204458-ClipEmbeddingFloat4.ts new file mode 100644 index 0000000000..3afa8c6d10 --- /dev/null +++ b/server/libs/infra/src/db/migrations/1679901204458-ClipEmbeddingFloat4.ts @@ -0,0 +1,17 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class ClipEmbeddingFloat41679901204458 implements MigrationInterface { + name = 'ClipEmbeddingFloat41679901204458'; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "smart_info" ALTER COLUMN "clipEmbedding" TYPE real array USING "clipEmbedding"::real array`, + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "smart_info" ALTER COLUMN "clipEmbedding" TYPE numeric(20,19) array USING "clipEmbedding"::numeric(20,19) array`, + ); + } +}