Skip to content

Commit

Permalink
refactored i m n r
Browse files Browse the repository at this point in the history
  • Loading branch information
AnatolyUss committed Sep 15, 2020
1 parent c46aa27 commit 4d71a00
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/IndexAndKeyProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import * as extraConfigProcessor from './ExtraConfigProcessor';
/**
* Creates primary key and indices.
*/
export default async function(conversion: Conversion, tableName: string): Promise<void> {
export default async (conversion: Conversion, tableName: string): Promise<void> => {
const logTitle: string = 'IndexAndKeyProcessor::default';
const originalTableName: string = extraConfigProcessor.getTableName(conversion, tableName, true);
const params: IDBAccessQueryParams = {
Expand Down Expand Up @@ -90,4 +90,4 @@ export default async function(conversion: Conversion, tableName: string): Promis
await Promise.all(addIndexPromises);
const successMsg: string = `\t--[${ logTitle }] "${ conversion._schema }"."${ tableName }": PK/indices are successfully set...`;
log(conversion, successMsg, conversion._dicTables[tableName].tableLogPath);
}
};
20 changes: 10 additions & 10 deletions src/MigrationStateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ import Conversion from './Conversion';
/**
* Returns the state logs table name.
*/
export function getStateLogsTableName(conversion: Conversion, getRowName: boolean = false): string {
export const getStateLogsTableName = (conversion: Conversion, getRowName: boolean = false): string => {
const rowName: string = `state_logs_${ conversion._schema }${ conversion._mySqlDbName }`;
return getRowName ? rowName : `"${ conversion._schema }"."${ rowName }"`;
}
};

/**
* Retrieves state-log.
*/
export async function get(conversion: Conversion, param: string): Promise<boolean> {
export const get = async (conversion: Conversion, param: string): Promise<boolean> => {
const params: IDBAccessQueryParams = {
conversion: conversion,
caller: 'MigrationStateManager::get',
Expand All @@ -48,12 +48,12 @@ export async function get(conversion: Conversion, param: string): Promise<boolea

const result: DBAccessQueryResult = await DBAccess.query(params);
return result.data.rows[0][param];
}
};

/**
* Updates the state-log.
*/
export async function set(conversion: Conversion, ...states: string[]): Promise<void> {
export const set = async (conversion: Conversion, ...states: string[]): Promise<void> => {
const statesSql: string = states.map((state: string) => `${ state } = TRUE`).join(',');
const params: IDBAccessQueryParams = {
conversion: conversion,
Expand All @@ -65,12 +65,12 @@ export async function set(conversion: Conversion, ...states: string[]): Promise<
};

await DBAccess.query(params);
}
};

/**
* Creates the "{schema}"."state_logs_{self._schema + self._mySqlDbName}" temporary table.
*/
export async function createStateLogsTable(conversion: Conversion): Promise<Conversion> {
export const createStateLogsTable = async (conversion: Conversion): Promise<Conversion> => {
const logTitle: string = 'MigrationStateManager::createStateLogsTable';
const sql: string = `CREATE TABLE IF NOT EXISTS ${ getStateLogsTableName(conversion) }(
"tables_loaded" BOOLEAN, "per_table_constraints_loaded" BOOLEAN, "foreign_keys_loaded" BOOLEAN, "views_loaded" BOOLEAN);`;
Expand Down Expand Up @@ -101,12 +101,12 @@ export async function createStateLogsTable(conversion: Conversion): Promise<Conv
const msg: string = `\t--[${ logTitle }] table ${ getStateLogsTableName(conversion) } is created...`;
log(conversion, msg);
return conversion;
}
};

/**
* Drop the "{schema}"."state_logs_{self._schema + self._mySqlDbName}" temporary table.
*/
export async function dropStateLogsTable(conversion: Conversion): Promise<Conversion> {
export const dropStateLogsTable = async (conversion: Conversion): Promise<Conversion> => {
const params: IDBAccessQueryParams = {
conversion: conversion,
caller: 'MigrationStateManager::dropStateLogsTable',
Expand All @@ -118,4 +118,4 @@ export async function dropStateLogsTable(conversion: Conversion): Promise<Conver

await DBAccess.query(params);
return conversion;
}
};
4 changes: 2 additions & 2 deletions src/NullProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import * as extraConfigProcessor from './ExtraConfigProcessor';
* Defines which columns of the given table can contain the "NULL" value.
* Sets an appropriate constraint, if need.
*/
export default async function(conversion: Conversion, tableName: string): Promise<void> {
export default async (conversion: Conversion, tableName: string): Promise<void> => {
const logTitle: string = 'NullProcessor::default';
const msg: string = `\t--[${ logTitle }] Defines "NOT NULLs" for table: "${ conversion._schema }"."${ tableName }"`;
log(conversion, msg, conversion._dicTables[tableName].tableLogPath);
Expand Down Expand Up @@ -58,4 +58,4 @@ export default async function(conversion: Conversion, tableName: string): Promis
});

await Promise.all(promises);
}
};
2 changes: 1 addition & 1 deletion src/ReportGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ export default (conversion: Conversion): void => {
\n\t--[generateReport] (hours:minutes:seconds)`;

log(conversion, output, undefined, () => process.exit(0));
}
};

0 comments on commit 4d71a00

Please sign in to comment.