fix: fix issue with cypress tests

This commit is contained in:
dr-carrot
2024-11-04 21:04:18 -05:00
parent ab5cdf5464
commit 94efdf7a18
4 changed files with 25 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ import type { DownloadingItem } from '@server/lib/downloadtracker';
import downloadTracker from '@server/lib/downloadtracker';
import { getSettings } from '@server/lib/settings';
import logger from '@server/logger';
import { DbAwareColumn } from '@server/utils/DbColumnHelper';
import { getHostname } from '@server/utils/getHostname';
import {
AfterLoad,
@@ -129,10 +130,10 @@ class Media {
@UpdateDateColumn()
public updatedAt: Date;
@Column({ type: 'timestamp without time zone', default: () => 'now()' })
@DbAwareColumn({ type: 'datetime', default: () => 'now()' })
public lastSeasonChange: Date;
@Column({ type: 'timestamp without time zone', default: () => 'now()' })
@DbAwareColumn({ type: 'datetime', default: () => 'now()' })
public mediaAddedAt: Date;
@Column({ nullable: true, type: 'int' })

View File

@@ -1,7 +1,7 @@
import type { MigrationInterface, QueryRunner } from 'typeorm';
export class AddBlacklist1699901142442 implements MigrationInterface {
name = 'AddBlacklist1699901142442';
export class AddBlacklist1730770837441 implements MigrationInterface {
name = 'AddBlacklist1730770837441';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(

View File

@@ -0,0 +1,20 @@
import { isPgsql } from '@server/datasource';
import type { ColumnOptions, ColumnType } from 'typeorm';
import { Column } from 'typeorm';
const pgTypeMapping: { [key: string]: ColumnType } = {
datetime: 'timestamp without time zone',
};
export function resolveDbType(pgType: ColumnType): ColumnType {
if (isPgsql && pgType.toString() in pgTypeMapping) {
return pgTypeMapping[pgType.toString()];
}
return pgType;
}
export function DbAwareColumn(columnOptions: ColumnOptions) {
if (columnOptions.type) {
columnOptions.type = resolveDbType(columnOptions.type);
}
return Column(columnOptions);
}