diff --git a/src/seeds/1616992561879-AddStreams.ts b/src/seeds/1616992561879-AddStreams.ts index 48a1b620..7c0acb97 100644 --- a/src/seeds/1616992561879-AddStreams.ts +++ b/src/seeds/1616992561879-AddStreams.ts @@ -1,18 +1,23 @@ -import { csvToSql } from 'src/utils/csvToSql'; +import * as fs from 'fs'; import { MigrationInterface, QueryRunner } from 'typeorm'; import { ulid } from 'ulid'; +import { csvToSql } from 'src/utils/csvToSql'; export class AddStreams1616992561879 implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { - ( - await csvToSql(__dirname + '/parl-2021-04-04/streams.csv', 'streams', { - emptyColumnCallback: () => { - return ulid(); - }, - }) - ) - .split(';') - .map(async (sql) => await queryRunner.query(sql)); + const streamsInput = __dirname + '/parl-2021-04-04/streams.csv'; + if (!fs.existsSync(streamsInput)) { + console.warn(`Missing streams seed input: ${streamsInput}`); + return; + } + + const sql = await csvToSql(streamsInput, 'streams', { + emptyColumnCallback: () => { + return ulid(); + }, + }); + + sql.split(';').forEach(async (sql) => await queryRunner.query(sql)); } public async down(queryRunner: QueryRunner): Promise {