added "include_tables" config option
This commit is contained in:
parent
09fc1764f7
commit
041849c2bd
|
@ -81,6 +81,12 @@
|
|||
],
|
||||
"exclude_tables": [],
|
||||
|
||||
"include_tables_description": [
|
||||
"List (Array) of tables, that will not be migrated.",
|
||||
"By default, nmig will migrate all tables."
|
||||
],
|
||||
"include_tables": [],
|
||||
|
||||
"migrate_only_data_description" : [
|
||||
"In order to skip schema migration, and just migrate data into a preset tables",
|
||||
"fill following array with preset table names.",
|
||||
|
|
|
@ -106,10 +106,15 @@ export default class Conversion {
|
|||
public readonly _noVacuum: string[];
|
||||
|
||||
/**
|
||||
* List of tables, that will not be migrated.List (Array) of tables, that will not be migrated.
|
||||
* List of tables, that will not be migrated.
|
||||
*/
|
||||
public readonly _excludeTables: string[];
|
||||
|
||||
/**
|
||||
* List of tables, that will be migrated.
|
||||
*/
|
||||
public readonly _includeTables: string[];
|
||||
|
||||
/**
|
||||
* The timestamp, at which the migration began.
|
||||
*/
|
||||
|
@ -209,6 +214,7 @@ export default class Conversion {
|
|||
this._notCreatedViewsPath = path.join(this._logsDirPath, 'not_created_views');
|
||||
this._noVacuum = this._config.no_vacuum === undefined ? [] : this._config.no_vacuum;
|
||||
this._excludeTables = this._config.exclude_tables === undefined ? [] : this._config.exclude_tables;
|
||||
this._includeTables = this._config.include_tables === undefined ? [] : this._config.include_tables;
|
||||
this._timeBegin = new Date();
|
||||
this._encoding = this._config.encoding === undefined ? 'utf8' : this._config.encoding;
|
||||
this._dataChunkSize = this._config.data_chunk_size === undefined ? 1 : +this._config.data_chunk_size;
|
||||
|
|
|
@ -62,7 +62,17 @@ export default async (conversion: Conversion): Promise<Conversion> => {
|
|||
await getMySqlVersion(conversion);
|
||||
const dbAccess: DBAccess = new DBAccess(conversion);
|
||||
const haveTablesLoaded: boolean = await migrationStateManager.get(conversion, 'tables_loaded');
|
||||
const sql: string = `SHOW FULL TABLES IN \`${ conversion._mySqlDbName }\`;`;
|
||||
let sql: string = `SHOW FULL TABLES IN \`${ conversion._mySqlDbName }\` WHERE 1 = 1`;
|
||||
|
||||
if (conversion._includeTables.length !== 0) {
|
||||
sql += ` AND Tables_in_${ conversion._mySqlDbName } IN(${ conversion._includeTables.map((table: string) => `"${table}"`).join(',') })`;
|
||||
}
|
||||
|
||||
if (conversion._excludeTables.length !== 0) {
|
||||
sql += ` AND Tables_in_${ conversion._mySqlDbName } NOT IN(${ conversion._excludeTables.map((table: string) => `"${table}"`).join(',') })`;
|
||||
}
|
||||
|
||||
sql += ';';
|
||||
const result: DBAccessQueryResult = await dbAccess.query('StructureLoader::default', sql, DBVendors.MYSQL, true, false);
|
||||
let tablesCnt: number = 0;
|
||||
let viewsCnt: number = 0;
|
||||
|
|
Loading…
Reference in a new issue