check if table exists and has items before running migration

This commit is contained in:
Zamitto 2024-05-17 17:12:03 -03:00
parent 5908544602
commit 622107a6f1

View File

@ -7,6 +7,16 @@ import { In, MigrationInterface, QueryRunner, Table } from "typeorm";
export class FixRepackUploadDate1715900413313 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const existsTable = await queryRunner.query(
`SELECT name FROM sqlite_master WHERE type='table' AND name='repack';`
);
if (!existsTable.length) return;
const repackCount = await queryRunner.manager.count(Repack);
if (!repackCount) return;
await queryRunner.createTable(
new Table({
name: "repack_temp",