This commit is contained in:
Tben 2023-08-12 17:03:48 +01:00
parent 5f1f7da024
commit 2fc92daa94
2 changed files with 16 additions and 22 deletions

View File

@ -9,8 +9,6 @@ require("dotenv").config({
path: path.resolve(process.cwd(), ".env"),
});
const varDatabaseDbHandler = require("./engine/utils/varDatabaseDbHandler");
const mysqlPath = process.platform?.match(/win/i) ? "'" + "C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin\\mysql.exe" + "'" : "mysql";
const mysqlDumpPath = process.platform?.match(/win/i) ? "'" + "C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin\\mysqldump.exe" + "'" : "mysqldump";
@ -29,11 +27,6 @@ if (!dbName?.match(/./)) {
process.exit();
}
varDatabaseDbHandler({
queryString: `CREATE DATABASE \`${dbName}\` IF NOT EXISTS CHARACTER SET utf8mb4 COLLATE utf8mb4_bin`,
database: dbName,
}).then((res) => {
console.log("Database creation attempt completed =>", res);
try {
let execSyncOptions = {
cwd: process.cwd(),
@ -41,7 +34,9 @@ varDatabaseDbHandler({
if (process.platform.match(/win/i)) execSyncOptions.shell = "bash.exe";
execSync(`${mysqlPath} -u ${process.env.DB_USERNAME} -p${process.env.DB_PASSWORD} ${dbName} < ${dumpFilePath}`, execSyncOptions);
const dump = execSync(`${mysqlPath} -u ${process.env.DB_USERNAME} -p${process.env.DB_PASSWORD} ${dbName} < ${dumpFilePath}`, execSyncOptions);
console.log("Dumped successfully", dump.toString());
console.log("Dumped successfully");
@ -51,4 +46,3 @@ varDatabaseDbHandler({
} catch (error) {
console.log("Dump Error: ", error.message);
}
});

View File

@ -1,6 +1,6 @@
{
"name": "datasquirel",
"version": "1.5.6",
"version": "1.5.7",
"description": "Cloud-based SQL data management tool",
"main": "index.js",
"bin": {