dbtasker 3.0.2 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/addcolumn.js CHANGED
@@ -249,7 +249,7 @@ async function addColumnIfNeeded(config, jsondata, separator) {
249
249
  }
250
250
  }
251
251
  }
252
- console.log(cstyler.cyan("Adding Column to tables are completed successfully."));
252
+ console.log(cstyler.bold.underline.hex("#b700ffff")("Adding Column to tables are completed successfully."));
253
253
  return true;
254
254
  } catch (err) {
255
255
  console.error(err.message);
package/altercolumn.js CHANGED
@@ -582,7 +582,7 @@ async function alterColumnIfNeeded(config, jsondata, forceupdatecolumn, separato
582
582
  }
583
583
  }
584
584
  }
585
- console.log(cstyler.cyan("Altering Column to tables are completed successfully."));
585
+ console.log(cstyler.bold.underline.hex("#b700ffff")("Alter Column process to tables are completed successfully."));
586
586
  return true;
587
587
  } catch (err) {
588
588
  console.error(err.message);
package/dbop.js CHANGED
@@ -209,9 +209,9 @@ async function databaseAddDeleteAlter(allconfig, jsondata, dropdb = false, dontt
209
209
  }
210
210
  }
211
211
  if (count > 0) {
212
- console.log(cstyler.green("All useless database have dropped"));
212
+ console.log(cstyler.bold.underline.hex("#b700ffff")("All useless database have dropped"));
213
213
  } else {
214
- console.log(cstyler.green("No database found to be dropped"));
214
+ console.log(cstyler.bold.underline.hex("#b700ffff")("No database found to be dropped"));
215
215
  }
216
216
  }
217
217
  return true;
package/index.js CHANGED
@@ -157,7 +157,7 @@ module.exports = async function (allconfig, table_json) {
157
157
  }
158
158
  // lets create tables if needed
159
159
  const tableop = require("./tableop");
160
- const createtable = await tableop.createTableifNeeded(config, jsondata, separator);
160
+ const createtable = await tableop.createTableIfNeeded(config, jsondata, separator);
161
161
  if (createtable === null) {
162
162
  console.log(cstyler.bold.underline.red("Error occurred during creating tables."));
163
163
  return;
package/package.json CHANGED
@@ -1,20 +1,34 @@
1
1
  {
2
2
  "name": "dbtasker",
3
- "version": "3.0.2",
4
- "description": "You can create database and table on your own with a lot of functionality.",
3
+ "version": "3.0.4",
4
+ "description": "dbtasker is a powerful and developer-friendly MySQL schema automation tool that converts JSON-based definitions into validated SQL that allows developers to declaratively define databases, tables, columns, indexes, and foreign keys using a flexible, case-insensitive JSON schema.",
5
5
  "license": "ISC",
6
6
  "author": "Md Nasiruddin Ahmed",
7
7
  "type": "commonjs",
8
8
  "main": "index.js",
9
9
  "keywords": [
10
10
  "database",
11
+ "db",
11
12
  "mysql",
12
13
  "table",
13
14
  "create",
14
- "mysql2",
15
15
  "alter",
16
16
  "modify",
17
- "mysql2"
17
+ "mysql2",
18
+ "dbtasker",
19
+ "automation",
20
+ "schema",
21
+ "dbtask",
22
+ "database-automation",
23
+ "schema-sync",
24
+ "schema-builder",
25
+ "database-task",
26
+ "database-utility",
27
+ "database-tool",
28
+ "create-table",
29
+ "alter-table",
30
+ "drop-table",
31
+ "foreign-key"
18
32
  ],
19
33
  "scripts": {
20
34
  "test": "echo \"Error: no test specified\" && exit 1"
package/tableop.js CHANGED
@@ -152,7 +152,7 @@ async function createTableQuery(config, tabledata, tableName, dbname) {
152
152
  return null;
153
153
  }
154
154
  }
155
- async function createTableifNeeded(config, jsondata, separator) {
155
+ async function createTableIfNeeded(config, jsondata, separator) {
156
156
  try {
157
157
  if (!fncs.isJsonObject(jsondata)) {
158
158
  return false;
@@ -209,9 +209,10 @@ async function createTableifNeeded(config, jsondata, separator) {
209
209
  }
210
210
  }
211
211
  }
212
+ console.log(cstyler.bold.underline.hex("#b700ffff")("Create table if needed process completed successfully."));
212
213
  return true;
213
214
  } catch (err) {
214
- console.error(cstyler.bold.red("Error occurred in createTableifNeeded function of ", moduleName, " module. Error details: "), err);
215
+ console.error(cstyler.bold.red("Error occurred in createTableIfNeeded function of ", moduleName, " module. Error details: "), err);
215
216
  return null;
216
217
  }
217
218
  }
@@ -268,6 +269,6 @@ async function dropTable(config, json_data, separator = "_") {
268
269
 
269
270
 
270
271
  module.exports = {
271
- createTableifNeeded,
272
+ createTableIfNeeded,
272
273
  dropTable
273
274
  };
package/validation.js CHANGED
@@ -236,7 +236,7 @@ async function JSONchecker(table_json, config, separator = "_") {
236
236
  return null;
237
237
  }
238
238
  // get all mysql table engines
239
- const mysqlEngines = await fncs.getMySQLEngines(config);
239
+ let mysqlEngines = await fncs.getMySQLEngines(config);
240
240
  if (!fncs.isJsonObject(mysqlEngines)) {
241
241
  console.error(cstyler.red.bold("There is a problem connecting to the database. Please check database info or connection."));
242
242
  return null;
@@ -1220,9 +1220,16 @@ async function JSONchecker(table_json, config, separator = "_") {
1220
1220
  }
1221
1221
  } else if (enginekey.includes(columnName.toLowerCase())) {
1222
1222
  const engvalue = table_json[databaseName][tableName][columnName];
1223
- if (Object.keys(mysqlEngines).includes(engvalue)) {
1224
- if (mysqlEngines[engvalue].support === "YES") {
1225
- contentObj[databaseName][tableName]._engine_ = engvalue;
1223
+ if (Object.keys(mysqlEngines).map(e => e.toUpperCase()).includes(fncs.stringifyAny(engvalue).toUpperCase())) {
1224
+ let ifyes;
1225
+ for(const key of Object.keys(mysqlEngines)) {
1226
+ if(key.toUpperCase() === fncs.stringifyAny(engvalue).toUpperCase()) {
1227
+ ifyes = key;
1228
+ break;
1229
+ }
1230
+ }
1231
+ if (mysqlEngines[ifyes].support === "YES") {
1232
+ contentObj[databaseName][tableName]._engine_ = ifyes;
1226
1233
  } else {
1227
1234
  badengine.push(
1228
1235
  `${cstyler.blue('Database:')} ${cstyler.hex("#00d9ffff")(databaseName)} ${cstyler.blue('> Table:')} ${cstyler.hex("#00d9ffff")(tableName)} ${cstyler.blue('> Engine key:')} ${cstyler.hex("#00d9ffff")(columnName)} ${cstyler.blue("Engine name: ")} ${cstyler.hex("#00d9ffff")(engvalue)} ${cstyler.red('- The storage engine exists in MySQL source code but is not available on this server.')}`
@@ -1230,7 +1237,7 @@ async function JSONchecker(table_json, config, separator = "_") {
1230
1237
  }
1231
1238
  } else {
1232
1239
  badengine.push(
1233
- `${cstyler.blue('Database:')} ${cstyler.hex("#00d9ffff")(databaseName)} ${cstyler.blue('> Table:')} ${cstyler.hex("#00d9ffff")(tableName)} ${cstyler.blue('> Engine key:')} ${cstyler.hex("#00d9ffff")(columnName)} ${cstyler.blue("Engine name:")} ${cstyler.hex("#00d9ffff")(engvalue)} ${cstyler.red('- must have a valid engine value')}`
1240
+ `${cstyler.blue('Database:')} ${cstyler.hex("#00d9ffff")(databaseName)} ${cstyler.blue('> Table:')} ${cstyler.hex("#00d9ffff")(tableName)} ${cstyler.blue('> Engine key:')} ${cstyler.hex("#00d9ffff")(columnName)} ${cstyler.blue("Engine name:")} ${cstyler.underline.bold.hex("#00d9ffff")(engvalue)} ${cstyler.bold.red('- is not a valid MySQL storage engine name.')}`
1234
1241
  );
1235
1242
  }
1236
1243
  } else if (commetnkey.includes(columnName.toLowerCase())) {