This commit is contained in:
Benjamin Toby
2024-11-06 14:37:44 +01:00
parent 83d261362f
commit d9e1ac7f54
215 changed files with 403 additions and 401 deletions
+2 -7
View File
@@ -19,18 +19,13 @@ const targetDatabase = dbFlag >= 0 ? process.argv[dbFlag + 1] : null;
* @param {string} [params.dbFnArg] - User Database full name
*/
async function createDbFromSchema({ userId, dbFnArg }) {
/**
* Grab Schema
*
* @description Grab Schema
*/
const path = userId
const schemaPath = userId
? `${String(
process.env.DSQL_USER_DB_SCHEMA_PATH
)}/user-${userId}/main.json`
: "../jsonData/dbSchemas/main.json";
/** @type {import("../package-shared/types").DSQL_DatabaseSchemaType[]} */
const dbSchema = require(path);
const dbSchema = require(schemaPath);
// await createDatabasesFromSchema(dbSchema);
@@ -57,12 +57,19 @@ module.exports = function generateColumnDescription({
////////////////////////////////////////
// if (String(fieldEntryText).match(/ UUID$/)) {
// fieldEntryText += ` DEFAULT UUID()`;
// } else
if (nullValue) {
fieldEntryText += " DEFAULT NULL";
} else if (defaultValueLiteral) {
fieldEntryText += ` DEFAULT ${defaultValueLiteral}`;
} else if (defaultValue) {
fieldEntryText += ` DEFAULT '${defaultValue}'`;
if (String(defaultValue).match(/uuid\(\)/i)) {
fieldEntryText += ` DEFAULT UUID()`;
} else {
fieldEntryText += ` DEFAULT '${defaultValue}'`;
}
} else if (notNullValue) {
fieldEntryText += ` NOT NULL`;
}