Skip to content

Commit 973e419

Browse files
author
Umed Khudoiberdiev
committed
fixed bug in migrations
1 parent 048770a commit 973e419

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/driver/mysql/MysqlQueryRunner.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ export class MysqlQueryRunner implements QueryRunner {
462462
async hasTable(tableSchemaOrPath: TableSchema|string): Promise<boolean> {
463463
const parsedTablePath = this.parseTablePath(tableSchemaOrPath);
464464
const sql = `SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '${parsedTablePath.database}' AND TABLE_NAME = '${parsedTablePath.tableName}'`;
465+
console.log(sql);
465466
const result = await this.query(sql);
466467
return result.length ? true : false;
467468
}
@@ -795,22 +796,16 @@ export class MysqlQueryRunner implements QueryRunner {
795796
await this.query(upQuery);
796797
}
797798

798-
protected parseTablePath(tableSchemaOrPath: TableSchema|string): any {
799+
protected parseTablePath(tableSchemaOrPath: TableSchema|string) {
799800
if (tableSchemaOrPath instanceof TableSchema) {
800-
const database = tableSchemaOrPath.database || this.driver.database;
801-
if (!database)
802-
throw new Error(`No database specified`);
803801
return {
804-
database: database,
802+
database: tableSchemaOrPath.database || this.driver.database,
805803
tableName: tableSchemaOrPath.name
806804
};
807805
} else {
808-
const database = tableSchemaOrPath.split(".")[0] || this.driver.database;
809-
if (!database)
810-
throw new Error(`No database specified`);
811806
return {
812-
database: database,
813-
tableName: tableSchemaOrPath.indexOf(".") === -1 ? tableSchemaOrPath : tableSchemaOrPath.split(".")[1]
807+
database: tableSchemaOrPath.indexOf(".") !== -1 ? tableSchemaOrPath.split(".")[0] : this.driver.database,
808+
tableName: tableSchemaOrPath.indexOf(".") !== -1 ? tableSchemaOrPath.split(".")[1] : tableSchemaOrPath
814809
};
815810
}
816811
}

0 commit comments

Comments
 (0)