Fix typeorm migrations (#297)

* fix: remove config parameter from typeorm cli and update config

the config parameter is no longer supported since version 0.3
the config now needs to export a DataSource object to work with the 0.3 cli

* fix: update all typeorm entities and migrations to be aligned with database structure

* Fixed test-util import databaseConfig

* Fixed column mismatch in raw query with new migration

* Remove dist build directory when starting dev server

Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
Zack Pollard
2022-07-04 20:20:43 +01:00
committed by GitHub
parent 355038a91a
commit e6d30d72fa
12 changed files with 128 additions and 17 deletions

View File

@@ -1,9 +1,9 @@
import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn, Unique } from 'typeorm';
import {Column, Entity, JoinColumn, ManyToOne, OneToOne, PrimaryGeneratedColumn, Unique} from 'typeorm';
import { AlbumEntity } from './album.entity';
import { AssetEntity } from './asset.entity';
@Entity('asset_album')
@Unique('PK_unique_asset_in_album', ['albumId', 'assetId'])
@Unique('UQ_unique_asset_in_album', ['albumId', 'assetId'])
export class AssetAlbumEntity {
@PrimaryGeneratedColumn()
id!: string;
@@ -12,6 +12,7 @@ export class AssetAlbumEntity {
albumId!: string;
@Column()
@OneToOne(() => AssetEntity, (entity) => entity.id)
assetId!: string;
@ManyToOne(() => AlbumEntity, (album) => album.assets, {

View File

@@ -26,10 +26,10 @@ export class AssetEntity {
@Column({ type: 'varchar', nullable: true })
resizePath!: string | null;
@Column({ type: 'varchar', nullable: true })
@Column({ type: 'varchar', nullable: true, default: '' })
webpPath!: string | null;
@Column({ type: 'varchar', nullable: true })
@Column({ type: 'varchar', nullable: true, default: '' })
encodedVideoPath!: string;
@Column()

View File

@@ -73,4 +73,19 @@ export class ExifEntity {
@OneToOne(() => AssetEntity, { onDelete: 'CASCADE', nullable: true })
@JoinColumn({ name: 'assetId', referencedColumnName: 'id' })
asset?: ExifEntity;
@Index("exif_text_searchable", { synchronize: false })
@Column({
type: 'tsvector',
generatedType: 'STORED',
asExpression: `TO_TSVECTOR('english',
COALESCE(make, '') || ' ' ||
COALESCE(model, '') || ' ' ||
COALESCE(orientation, '') || ' ' ||
COALESCE("lensModel", '') || ' ' ||
COALESCE("city", '') || ' ' ||
COALESCE("state", '') || ' ' ||
COALESCE("country", ''))`
})
exifTextSearchableColumn!: string
}

View File

@@ -5,13 +5,13 @@ export class UserEntity {
@PrimaryGeneratedColumn('uuid')
id!: string;
@Column()
@Column({ default: '' })
firstName!: string;
@Column()
@Column({ default: '' })
lastName!: string;
@Column()
@Column({ default: false })
isAdmin!: boolean;
@Column()
@@ -23,10 +23,10 @@ export class UserEntity {
@Column({ select: false })
salt?: string;
@Column()
@Column({ default: '' })
profileImagePath!: string;
@Column()
@Column({ default: true })
shouldChangePassword!: boolean;
@CreateDateColumn()