add "drop table" to query runner

This commit is contained in:
Roman Lakhtadyr 2017-05-16 20:57:52 +03:00
parent 911a03e619
commit 4e2c095ba5
8 changed files with 60 additions and 0 deletions

View File

@ -435,6 +435,13 @@ export class MongoQueryRunner implements QueryRunner {
throw new Error(`Schema update queries are not supported by MongoDB driver.`);
}
/**
* Drops the table.
*/
async dropTable(tableName: string): Promise<void> {
throw new Error(`Schema update queries are not supported by MongoDB driver.`);
}
/**
* Checks if column with the given name exist in the given table.
*/

View File

@ -359,6 +359,14 @@ export class MysqlQueryRunner implements QueryRunner {
await this.query(sql);
}
/**
* Drop the table.
*/
async dropTable(tableName: String): Promise<void> {
let sql = `DROP TABLE \`${tableName}\``;
await this.query(sql);
}
/**
* Checks if column with the given name exist in the given table.
*/

View File

@ -388,6 +388,14 @@ AND cons.constraint_name = cols.constraint_name AND cons.owner = cols.owner ORDE
await this.query(sql);
}
/**
* Drops the table.
*/
async dropTable(tableName: string): Promise<void> {
let sql = `DROP TABLE "${tableName}"`;
await this.query(sql);
}
/**
* Checks if column with the given name exist in the given table.
*/

View File

@ -373,6 +373,14 @@ where constraint_type = 'PRIMARY KEY' AND c.table_schema = '${this.schemaName}'
await this.query(sql);
}
/**
* Drops the table.
*/
async dropTable(tableName: string): Promise<void> {
let sql = `DROP TABLE "${tableName}"`;
await this.query(sql);
}
/**
* Checks if column with the given name exist in the given table.
*/

View File

@ -399,6 +399,14 @@ export class SqliteQueryRunner implements QueryRunner {
await this.query(sql);
}
/**
* Drops the table.
*/
async dropTable(tableName: string): Promise<void> {
let sql = `DROP TABLE "${tableName}"`;
await this.query(sql);
}
/**
* Checks if column with the given name exist in the given table.
*/

View File

@ -445,6 +445,14 @@ export class SqlServerQueryRunner implements QueryRunner {
await this.query(sql);
}
/**
* Drops the table.
*/
async dropTable(tableName: string): Promise<void> {
let sql = `DROP TABLE "${tableName}"`;
await this.query(sql);
}
/**
* Checks if column with the given name exist in the given table.
*/

View File

@ -409,6 +409,14 @@ export class WebsqlQueryRunner implements QueryRunner {
await this.query(sql);
}
/**
* Drops the table.
*/
async dropTable(tableName: string): Promise<void> {
let sql = `DROP TABLE "${tableName}"`;
await this.query(sql);
}
/**
* Checks if column with the given name exist in the given table.
*/

View File

@ -106,6 +106,11 @@ export interface QueryRunner {
*/
createTable(table: TableSchema): Promise<void>;
/**
* Drops the table.
*/
dropTable(tableName: string): Promise<void>;
/**
* Checks if column with the given name exist in the given table.
*/