mirror of
https://github.com/immich-app/immich.git
synced 2024-12-29 11:24:37 +02:00
fix(server): use jasonnnnnnnnnb (#9539)
This commit is contained in:
parent
d8eca168ca
commit
936a46b4ed
@ -6,7 +6,7 @@ export class SystemMetadataEntity<T extends keyof SystemMetadata = SystemMetadat
|
||||
@PrimaryColumn({ type: 'varchar' })
|
||||
key!: T;
|
||||
|
||||
@Column({ type: 'jsonb', default: '{}', transformer: { to: JSON.stringify, from: JSON.parse } })
|
||||
@Column({ type: 'jsonb' })
|
||||
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…
Reference in New Issue
Block a user