@minatojs/driver-mysql
Advanced tools
Comparing version 2.3.6 to 2.4.1
@@ -220,3 +220,5 @@ "use strict"; | ||
for (const key in fields) { | ||
const { initial, nullable = true } = fields[key]; | ||
const { deprecated, initial, nullable = true } = fields[key]; | ||
if (deprecated) | ||
continue; | ||
const legacy = [key, ...fields[key].legacy || []]; | ||
@@ -276,3 +278,3 @@ const column = columns.find((info) => legacy.includes(info.COLUMN_NAME)); | ||
logger.info("auto creating table %c", name); | ||
return this.queue(`CREATE TABLE ?? (${create.join(", ")}) COLLATE = ?`, [name, this.config.charset]); | ||
return this.query(`CREATE TABLE ${(0, import_sql_utils.escapeId)(name)} (${create.join(", ")}) COLLATE = ${this.sql.escape(this.config.charset)}`); | ||
} | ||
@@ -285,4 +287,16 @@ const operations = [ | ||
logger.info("auto updating table %c", name); | ||
await this.queue(`ALTER TABLE ?? ${operations.join(", ")}`, [name]); | ||
await this.query(`ALTER TABLE ${(0, import_sql_utils.escapeId)(name)} ${operations.join(", ")}`); | ||
} | ||
const dropKeys = []; | ||
this.migrate(name, { | ||
error: logger.warn, | ||
before: (keys) => keys.every((key) => columns.some((info) => info.COLUMN_NAME === key)), | ||
after: (keys) => dropKeys.push(...keys), | ||
finalize: async () => { | ||
if (!dropKeys.length) | ||
return; | ||
logger.info("auto migrating table %c", name); | ||
await this.query(`ALTER TABLE ${(0, import_sql_utils.escapeId)(name)} ${dropKeys.map((key) => `DROP ${(0, import_sql_utils.escapeId)(key)}`).join(", ")}`); | ||
} | ||
}); | ||
} | ||
@@ -289,0 +303,0 @@ query(sql) { |
{ | ||
"name": "@minatojs/driver-mysql", | ||
"version": "2.3.6", | ||
"version": "2.4.1", | ||
"description": "MySQL Driver for Minato", | ||
@@ -28,10 +28,10 @@ "main": "lib/index.js", | ||
"peerDependencies": { | ||
"@minatojs/core": "^2.2.2" | ||
"@minatojs/core": "^2.3.1" | ||
}, | ||
"devDependencies": { | ||
"@minatojs/tests": "^1.4.0", | ||
"@minatojs/tests": "^1.5.0", | ||
"@types/mysql": "^2.15.21" | ||
}, | ||
"dependencies": { | ||
"@minatojs/sql-utils": "^4.0.2", | ||
"@minatojs/sql-utils": "^4.0.3", | ||
"@vlasky/mysql": "^2.18.6", | ||
@@ -38,0 +38,0 @@ "cosmokit": "^1.4.1", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50998
549
Updated@minatojs/sql-utils@^4.0.3