added extra methods to query runner and implemented them in mysql driver

This commit is contained in:
Umed Khudoiberdiev 2016-12-11 09:33:48 +05:00
parent 9334500861
commit 31d5a76f5f

View File

@ -1,7 +1,6 @@
import {ColumnSchema} from "../schema-builder/schema/ColumnSchema";
import {ColumnMetadata} from "../metadata/ColumnMetadata";
import {TableSchema} from "../schema-builder/schema/TableSchema";
import {NamingStrategyInterface} from "../naming-strategy/NamingStrategyInterface";
import {ForeignKeySchema} from "../schema-builder/schema/ForeignKeySchema";
import {IndexSchema} from "../schema-builder/schema/IndexSchema";
@ -82,12 +81,12 @@ export interface QueryRunner {
/**
* Loads all tables (with given names) from the database and creates a TableSchema from them.
*/
loadTableSchema(tableName: string, namingStrategy: NamingStrategyInterface): Promise<TableSchema|undefined>;
loadTableSchema(tableName: string): Promise<TableSchema|undefined>;
/**
* Loads all tables (with given names) from the database and creates a TableSchema from them.
*/
loadTableSchemas(tableNames: string[], namingStrategy: NamingStrategyInterface): Promise<TableSchema[]>;
loadTableSchemas(tableNames: string[]): Promise<TableSchema[]>;
/**
* Checks if table with the given name exist in the database.
@ -102,69 +101,109 @@ export interface QueryRunner {
/**
* Checks if column with the given name exist in the given table.
*/
hasColumn(table: TableSchema, columnName: string): Promise<boolean>;
hasColumn(tableName: string, columnName: string): Promise<boolean>;
/**
* Creates a new column in the table.
* Adds a new column in the table.
*/
addColumn(tableSchema: TableSchema, column: ColumnSchema): Promise<void>;
addColumn(tableName: string, column: ColumnSchema): Promise<void>;
/**
* Creates new columns in the table.
* Adds a new column in the table.
*/
addColumns(tableSchema: TableSchema, columns: ColumnSchema[]): Promise<void>;
addColumn(table: TableSchema, column: ColumnSchema): Promise<void>;
/**
* Adds new columns in the table.
*/
addColumns(tableSchema: string, columns: ColumnSchema[]): Promise<void>;
/**
* Adds new columns in the table.
*/
addColumns(table: TableSchema, columns: ColumnSchema[]): Promise<void>;
// todo: renameColumn ?
/**
* Changes a column in the table.
*/
changeColumn(tableSchema: TableSchema, newColumn: ColumnSchema, oldColumn: ColumnSchema): Promise<void>;
changeColumn(table: TableSchema, newColumn: ColumnSchema, oldColumn: ColumnSchema): Promise<void>;
/**
* Changes a columns in the table.
*/
changeColumns(tableSchema: TableSchema, changedColumns: { newColumn: ColumnSchema, oldColumn: ColumnSchema }[]): Promise<void>;
changeColumns(table: TableSchema, changedColumns: { newColumn: ColumnSchema, oldColumn: ColumnSchema }[]): Promise<void>;
/**
* Drops the column in the table.
*/
dropColumn(dbTable: TableSchema, column: ColumnSchema): Promise<void>;
dropColumn(tableName: string, columnName: string): Promise<void>;
/**
* Drops the column in the table.
*/
dropColumn(tableName: string, columnName: string): Promise<void>;
/**
* Drops the column in the table.
*/
dropColumn(table: TableSchema, column: ColumnSchema): Promise<void>;
/**
* Drops the columns in the table.
*/
dropColumns(dbTable: TableSchema, columns: ColumnSchema[]): Promise<void>;
dropColumns(tableName: string, columnNames: string[]): Promise<void>;
/**
* Drops the columns in the table.
*/
dropColumns(table: TableSchema, columns: ColumnSchema[]): Promise<void>;
/**
* Updates primary keys in the table.
*/
updatePrimaryKeys(dbTable: TableSchema): Promise<void>;
updatePrimaryKeys(table: TableSchema): Promise<void>;
/**
* Creates a new foreign key.
*/
createForeignKey(dbTable: TableSchema, foreignKey: ForeignKeySchema): Promise<void>;
createForeignKey(tableName: string, foreignKey: ForeignKeySchema): Promise<void>;
/**
* Creates a new foreign key.
*/
createForeignKey(tableSchema: TableSchema, foreignKey: ForeignKeySchema): Promise<void>;
/**
* Creates a new foreign keys.
*/
createForeignKeys(dbTable: TableSchema, foreignKeys: ForeignKeySchema[]): Promise<void>;
createForeignKeys(table: TableSchema, foreignKeys: ForeignKeySchema[]): Promise<void>;
/**
* Drops a foreign keys from the table.
*/
dropForeignKey(tableSchema: TableSchema, foreignKey: ForeignKeySchema): Promise<void>;
dropForeignKey(table: string, foreignKey: ForeignKeySchema): Promise<void>;
/**
* Drops a foreign keys from the table.
*/
dropForeignKeys(tableSchema: TableSchema, foreignKeys: ForeignKeySchema[]): Promise<void>;
dropForeignKey(table: TableSchema, foreignKey: ForeignKeySchema): Promise<void>;
/**
* Drops a foreign keys from the table.
*/
dropForeignKeys(table: string, foreignKeys: ForeignKeySchema[]): Promise<void>;
/**
* Drops a foreign keys from the table.
*/
dropForeignKeys(table: TableSchema, foreignKeys: ForeignKeySchema[]): Promise<void>;
/**
* Creates a new index.
*/
createIndex(index: IndexSchema): Promise<void>;
createIndex(tableName: string, index: IndexSchema): Promise<void>;
/**
* Drops an index from the table.