Files
immich/server/src/infra/migrations/1709763765506-AddExtensionToOriginalFileName.ts
Alex 3da2b05428 chore(server): save original file name with extension (#7679)
* chore(server): save original file name with extension

* extract extension

* update e2e test

* update e2e test

* download archive

* fix download archive appending name

* pr feedback

* remove unused code

* test

* unit test

* remove unused code

* migration

* noops

* pr feedback

* Update server/src/domain/download/download.service.ts

Co-authored-by: Mert <101130780+mertalev@users.noreply.github.com>

---------

Co-authored-by: Mert <101130780+mertalev@users.noreply.github.com>
2024-03-07 02:34:55 +00:00

21 lines
691 B
TypeScript

import { MigrationInterface, QueryRunner } from 'typeorm';
export class AddExtensionToOriginalFileName1709763765506 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
WITH extension AS (WITH cte AS (SELECT a.id, STRING_TO_ARRAY(a."originalPath", '.')::TEXT[] AS arr
FROM assets a)
SELECT cte.id, cte.arr[ARRAY_UPPER(cte.arr, 1)] AS "ext"
FROM cte)
UPDATE assets
SET "originalFileName" = assets."originalFileName" || '.' || extension."ext"
FROM extension
INNER JOIN assets a ON a.id = extension.id;
`);
}
public async down(): Promise<void> {
// noop
}
}