mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
fix(server): change the createdAt and modifiedAt to the correct type in database (#591)
* Added migration files * Remove type casting in sql query
This commit is contained in:
parent
7f6837c751
commit
b081eda76f
3 changed files with 34 additions and 13 deletions
|
|
@ -32,10 +32,10 @@ export class AssetEntity {
|
|||
@Column({ type: 'varchar', nullable: true, default: '' })
|
||||
encodedVideoPath!: string;
|
||||
|
||||
@Column()
|
||||
@Column({ type: 'timestamptz' })
|
||||
createdAt!: string;
|
||||
|
||||
@Column()
|
||||
@Column({ type: 'timestamptz' })
|
||||
modifiedAt!: string;
|
||||
|
||||
@Column({ type: 'boolean', default: false })
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class FixTimestampDataTypeInAssetTable1662427365521 implements MigrationInterface {
|
||||
name = 'FixTimestampDataTypeInAssetTable1662427365521';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "exif" ALTER COLUMN "exifTextSearchableColumn" SET NOT NULL`);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "assets" ALTER COLUMN "createdAt" TYPE timestamptz USING "createdAt"::timestamptz`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "assets" ALTER COLUMN "modifiedAt" TYPE timestamptz USING "createdAt"::timestamptz`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "assets" ALTER COLUMN "createdAt" TYPE varchar USING "createdAt"::varchar`);
|
||||
await queryRunner.query(`ALTER TABLE "assets" ALTER COLUMN "modifiedAt" TYPE varchar USING "createdAt"::varchar`);
|
||||
await queryRunner.query(`ALTER TABLE "exif" ALTER COLUMN "exifTextSearchableColumn" DROP NOT NULL`);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue