mirror of
https://github.com/immich-app/immich.git
synced 2025-01-10 13:56:47 +01:00
db628cec11
* fix(server): cannot delete an asset if presented in album * added migration * preserve correct migration
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import {
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
JoinTable,
|
|
ManyToMany,
|
|
ManyToOne,
|
|
OneToMany,
|
|
PrimaryGeneratedColumn,
|
|
UpdateDateColumn,
|
|
} from 'typeorm';
|
|
import { SharedLinkEntity } from './shared-link.entity';
|
|
import { AssetEntity } from './asset.entity';
|
|
import { UserEntity } from './user.entity';
|
|
|
|
@Entity('albums')
|
|
export class AlbumEntity {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id!: string;
|
|
|
|
@ManyToOne(() => UserEntity, { onDelete: 'CASCADE', onUpdate: 'CASCADE', nullable: false })
|
|
owner!: UserEntity;
|
|
|
|
@Column()
|
|
ownerId!: string;
|
|
|
|
@Column({ default: 'Untitled Album' })
|
|
albumName!: string;
|
|
|
|
@CreateDateColumn({ type: 'timestamptz' })
|
|
createdAt!: string;
|
|
|
|
@UpdateDateColumn({ type: 'timestamptz' })
|
|
updatedAt!: string;
|
|
|
|
@ManyToOne(() => AssetEntity, { nullable: true, onDelete: 'SET NULL', onUpdate: 'CASCADE' })
|
|
albumThumbnailAsset!: AssetEntity | null;
|
|
|
|
@Column({ comment: 'Asset ID to be used as thumbnail', nullable: true })
|
|
albumThumbnailAssetId!: string | null;
|
|
|
|
@ManyToMany(() => UserEntity)
|
|
@JoinTable()
|
|
sharedUsers!: UserEntity[];
|
|
|
|
@ManyToMany(() => AssetEntity, (asset) => asset.albums)
|
|
@JoinTable()
|
|
assets!: AssetEntity[];
|
|
|
|
@OneToMany(() => SharedLinkEntity, (link) => link.album)
|
|
sharedLinks!: SharedLinkEntity[];
|
|
}
|