typeorm fixes
disable schema sync for smart entities
This commit is contained in:
parent
1338c5fd59
commit
1fe9075d11
9 changed files with 36 additions and 30 deletions
|
@ -2,7 +2,7 @@ import { Column, Entity, Index, ManyToOne, PrimaryGeneratedColumn } from 'typeor
|
||||||
import { AssetEntity } from './asset.entity';
|
import { AssetEntity } from './asset.entity';
|
||||||
import { PersonEntity } from './person.entity';
|
import { PersonEntity } from './person.entity';
|
||||||
|
|
||||||
@Entity('asset_faces')
|
@Entity('asset_faces', { synchronize: false })
|
||||||
@Index(['personId', 'assetId'])
|
@Index(['personId', 'assetId'])
|
||||||
export class AssetFaceEntity {
|
export class AssetFaceEntity {
|
||||||
@PrimaryGeneratedColumn('uuid')
|
@PrimaryGeneratedColumn('uuid')
|
||||||
|
@ -14,6 +14,7 @@ export class AssetFaceEntity {
|
||||||
@Column({ nullable: true, type: 'uuid' })
|
@Column({ nullable: true, type: 'uuid' })
|
||||||
personId!: string | null;
|
personId!: string | null;
|
||||||
|
|
||||||
|
@Index('face_index', { synchronize: false })
|
||||||
@Column({ type: 'float4', array: true, select: false })
|
@Column({ type: 'float4', array: true, select: false })
|
||||||
embedding!: number[];
|
embedding!: number[];
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ export class ExifEntity {
|
||||||
@Column({ type: 'varchar', nullable: true })
|
@Column({ type: 'varchar', nullable: true })
|
||||||
projectionType!: string | null;
|
projectionType!: string | null;
|
||||||
|
|
||||||
|
@Index('exif_city')
|
||||||
@Column({ type: 'varchar', nullable: true })
|
@Column({ type: 'varchar', nullable: true })
|
||||||
city!: string | null;
|
city!: string | null;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Column, Entity, JoinColumn, OneToOne, PrimaryColumn } from 'typeorm';
|
import { Column, Entity, JoinColumn, OneToOne, PrimaryColumn } from 'typeorm';
|
||||||
import { AssetEntity } from './asset.entity';
|
import { AssetEntity } from './asset.entity';
|
||||||
|
|
||||||
@Entity('smart_info')
|
@Entity('smart_info', { synchronize: false })
|
||||||
export class SmartInfoEntity {
|
export class SmartInfoEntity {
|
||||||
@OneToOne(() => AssetEntity, { onDelete: 'CASCADE', nullable: true })
|
@OneToOne(() => AssetEntity, { onDelete: 'CASCADE', nullable: true })
|
||||||
@JoinColumn({ name: 'assetId', referencedColumnName: 'id' })
|
@JoinColumn({ name: 'assetId', referencedColumnName: 'id' })
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Column, Entity, JoinColumn, OneToOne, PrimaryColumn } from 'typeorm';
|
import { Column, Entity, Index, JoinColumn, OneToOne, PrimaryColumn } from 'typeorm';
|
||||||
import { AssetEntity } from './asset.entity';
|
import { AssetEntity } from './asset.entity';
|
||||||
|
|
||||||
@Entity('smart_search')
|
@Entity('smart_search', { synchronize: false })
|
||||||
export class SmartSearchEntity {
|
export class SmartSearchEntity {
|
||||||
@OneToOne(() => AssetEntity, { onDelete: 'CASCADE', nullable: true })
|
@OneToOne(() => AssetEntity, { onDelete: 'CASCADE', nullable: true })
|
||||||
@JoinColumn({ name: 'assetId', referencedColumnName: 'id' })
|
@JoinColumn({ name: 'assetId', referencedColumnName: 'id' })
|
||||||
|
@ -10,6 +10,7 @@ export class SmartSearchEntity {
|
||||||
@PrimaryColumn()
|
@PrimaryColumn()
|
||||||
assetId!: string;
|
assetId!: string;
|
||||||
|
|
||||||
|
@Index('clip_index', { synchronize: false })
|
||||||
@Column({
|
@Column({
|
||||||
type: 'float4',
|
type: 'float4',
|
||||||
array: true,
|
array: true,
|
||||||
|
|
|
@ -34,7 +34,9 @@ export class UsePgVectors1700713871511 implements MigrationInterface {
|
||||||
SELECT si."assetId", si."clipEmbedding"
|
SELECT si."assetId", si."clipEmbedding"
|
||||||
FROM smart_info si
|
FROM smart_info si
|
||||||
WHERE "clipEmbedding" IS NOT NULL`);
|
WHERE "clipEmbedding" IS NOT NULL`);
|
||||||
}
|
|
||||||
|
await queryRunner.query(`ALTER TABLE smart_info DROP COLUMN IF EXISTS "clipEmbedding"`);
|
||||||
|
}
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
await queryRunner.query(`ALTER TABLE asset_faces ALTER COLUMN embedding TYPE real array`);
|
await queryRunner.query(`ALTER TABLE asset_faces ALTER COLUMN embedding TYPE real array`);
|
||||||
|
|
|
@ -5,12 +5,12 @@ export class AddCLIPEmbeddingIndex1700713994428 implements MigrationInterface {
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
await queryRunner.query(`
|
await queryRunner.query(`
|
||||||
CREATE INDEX IF NOT EXISTS clip_index ON smart_search
|
CREATE INDEX IF NOT EXISTS clip_index ON smart_search
|
||||||
USING vectors (embedding cosine_ops) WITH (options = $$
|
USING vectors (embedding cosine_ops) WITH (options = $$
|
||||||
[indexing.hnsw]
|
[indexing.hnsw]
|
||||||
m = 16
|
m = 16
|
||||||
ef_construction = 300
|
ef_construction = 300
|
||||||
$$);`);
|
$$);`);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
|
|
@ -5,12 +5,12 @@ export class AddFaceEmbeddingIndex1700714033632 implements MigrationInterface {
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
await queryRunner.query(`
|
await queryRunner.query(`
|
||||||
CREATE INDEX IF NOT EXISTS face_index ON asset_faces
|
CREATE INDEX IF NOT EXISTS face_index ON asset_faces
|
||||||
USING vectors (embedding cosine_ops) WITH (options = $$
|
USING vectors (embedding cosine_ops) WITH (options = $$
|
||||||
[indexing.hnsw]
|
[indexing.hnsw]
|
||||||
m = 16
|
m = 16
|
||||||
ef_construction = 300
|
ef_construction = 300
|
||||||
$$);`);
|
$$);`);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddExifCityIndex1700714105178 implements MigrationInterface {
|
|
||||||
name = 'AddExifCityIndex1700714105178';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`CREATE INDEX IF NOT EXISTS exif_city ON exif (city);`);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`DROP INDEX IF EXISTS exif_city;`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class AddExifCityIndex1701665867595 implements MigrationInterface {
|
||||||
|
name = 'AddExifCityIndex1701665867595'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`CREATE INDEX "exif_city" ON "exif" ("city") `);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`DROP INDEX "public"."exif_city"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue