mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
refactor(server): move files to separate table (#11861)
This commit is contained in:
parent
af3a793fe8
commit
7af6733665
32 changed files with 403 additions and 210 deletions
38
server/src/entities/asset-files.entity.ts
Normal file
38
server/src/entities/asset-files.entity.ts
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import { AssetEntity } from 'src/entities/asset.entity';
|
||||
import { AssetFileType } from 'src/enum';
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
Unique,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
@Unique('UQ_assetId_type', ['assetId', 'type'])
|
||||
@Entity('asset_files')
|
||||
export class AssetFileEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id!: string;
|
||||
|
||||
@Index('IDX_asset_files_assetId')
|
||||
@Column()
|
||||
assetId!: string;
|
||||
|
||||
@ManyToOne(() => AssetEntity, { onDelete: 'CASCADE', onUpdate: 'CASCADE' })
|
||||
asset?: AssetEntity;
|
||||
|
||||
@CreateDateColumn({ type: 'timestamptz' })
|
||||
createdAt!: Date;
|
||||
|
||||
@UpdateDateColumn({ type: 'timestamptz' })
|
||||
updatedAt!: Date;
|
||||
|
||||
@Column()
|
||||
type!: AssetFileType;
|
||||
|
||||
@Column()
|
||||
path!: string;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue