mirror of
https://github.com/immich-app/immich.git
synced 2025-03-25 02:41:37 -05:00
fix(server): use jasonnnnnnnnnb (#9539)
This commit is contained in:
parent
d8eca168ca
commit
936a46b4ed
2 changed files with 25 additions and 1 deletions
|
@ -6,7 +6,7 @@ export class SystemMetadataEntity<T extends keyof SystemMetadata = SystemMetadat
|
||||||
@PrimaryColumn({ type: 'varchar' })
|
@PrimaryColumn({ type: 'varchar' })
|
||||||
key!: T;
|
key!: T;
|
||||||
|
|
||||||
@Column({ type: 'jsonb', default: '{}', transformer: { to: JSON.stringify, from: JSON.parse } })
|
@Column({ type: 'jsonb' })
|
||||||
value!: SystemMetadata[T];
|
value!: SystemMetadata[T];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
24
server/src/migrations/1715890481637-FixJsonB.ts
Normal file
24
server/src/migrations/1715890481637-FixJsonB.ts
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||||
|
|
||||||
|
export class FixJsonB1715890481637 implements MigrationInterface {
|
||||||
|
name = 'FixJsonB1715890481637';
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE "system_metadata" ALTER COLUMN "value" DROP DEFAULT`);
|
||||||
|
const records = await queryRunner.query('SELECT "key", "value" FROM "system_metadata"');
|
||||||
|
for (const { key, value } of records) {
|
||||||
|
await queryRunner.query(`UPDATE "system_metadata" SET "value" = $1 WHERE "key" = $2`, [value, key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE "system_metadata" ALTER COLUMN "value" SET DEFAULT '{}'`);
|
||||||
|
const records = await queryRunner.query('SELECT "key", "value" FROM "system_metadata"');
|
||||||
|
for (const { key, value } of records) {
|
||||||
|
await queryRunner.query(`UPDATE "system_metadata" SET "value" = $1 WHERE "key" = $2`, [
|
||||||
|
JSON.stringify(JSON.stringify(value)),
|
||||||
|
key,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue