mirror of
https://github.com/typeorm/typeorm.git
synced 2025-12-08 21:26:23 +00:00
added migration interface
This commit is contained in:
parent
c55094810d
commit
4a8250c31e
@ -336,8 +336,8 @@ export class MysqlQueryRunner implements QueryRunner {
|
||||
/**
|
||||
* Checks if table with the given name exist in the database.
|
||||
*/
|
||||
async hasTable(table: TableSchema): Promise<boolean> {
|
||||
const sql = `SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '${this.dbName}' AND TABLE_NAME = '${table.name}'`;
|
||||
async hasTable(tableName: string): Promise<boolean> {
|
||||
const sql = `SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '${this.dbName}' AND TABLE_NAME = '${tableName}'`;
|
||||
const result = await this.query(sql);
|
||||
return result.length ? true : false;
|
||||
}
|
||||
|
||||
16
src/migration/MigrationInterface.ts
Normal file
16
src/migration/MigrationInterface.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import {Connection} from "../connection/Connection";
|
||||
import {QueryRunner} from "../query-runner/QueryRunner";
|
||||
|
||||
export interface MigrationInterface {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
up(queryRunner: QueryRunner, connection: Connection): Promise<any>;
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
down(queryRunner: QueryRunner, connection: Connection): Promise<any>;
|
||||
|
||||
}
|
||||
@ -92,7 +92,7 @@ export interface QueryRunner {
|
||||
/**
|
||||
* Checks if table with the given name exist in the database.
|
||||
*/
|
||||
hasTable(table: TableSchema): Promise<boolean>;
|
||||
hasTable(tableName: string): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Creates a new table from the given table metadata and column metadatas.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user