Registry / database / qy-mysql-upgrade

qy-mysql-upgrade

JSON →
library1.2.1jsnpmunverified

A MySQL schema upgrade tool for Node.js applications, version 1.2.1. It allows incremental database upgrades with version control, tracking applied changes. Supports both CommonJS and ESM. Differentiators: simple versioned migration files, automatic state tracking, and minimal configuration. Released irregularly; no major version changes noted.

npm install qy-mysql-upgrade
INSTALL
IMPORT
SIG · QY-MYSQL-UPGRADE
Q
qy-mysql-upgrade
databasejavascriptv1.2.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

upgrade
✓ import { upgrade } from 'qy-mysql-upgrade'
✗ const upgrade = require('qy-mysql-upgrade').upgrade
Default export not available; named export only. Use .default for CommonJS.
UpgradeOptions
✓ import type { UpgradeOptions } from 'qy-mysql-upgrade'
✗ import { UpgradeOptions } from 'qy-mysql-upgrade'
TypeScript type only; not a runtime value.
Migration
✓ import type { Migration } from 'qy-mysql-upgrade'
✗ const { Migration } = require('qy-mysql-upgrade')
Type only; not exported as a class.

Connects to MySQL and runs pending migrations from a local folder.

import { upgrade } from 'qy-mysql-upgrade'; import { createConnection } from 'mysql2/promise'; async function main() { const connection = await createConnection({ host: process.env.MYSQL_HOST ?? 'localhost', user: process.env.MYSQL_USER ?? 'root', password: process.env.MYSQL_PASSWORD ?? '', database: process.env.MYSQL_DB ?? 'test' }); await upgrade({ connection, migrationsDir: './migrations', tableName: 'schema_version' }); await connection.end(); } main().catch(console.error);
Debug
Known issues
gotchaMigrations must be in ascending order by version number (numeric filenames). Non-numeric names will be ignored.
fix
Name migration files like '001_init.sql', '002_add_users.sql' etc.
affects: all
gotchaThe 'tableName' option defaults to 'migrations'; if a table with that name exists for another purpose, upgrade will fail.
fix
Explicitly set 'tableName' to a unique name like 'schema_version'.
affects: >=1.0.0
gotchaMySQL connection must be created with mysql2/promise; callback-based connections are not supported.
fix
Use 'mysql2/promise' and call createConnection().
affects: >=1.0.0
Errors
Common errors & fixes
Error: ENOENT: no such file or directory, scandir './migrations'
Migrations directory path does not exist or is incorrect relative to CWD.
fix
Ensure the migrationsDir option points to an existing directory, e.g., path.resolve(__dirname, 'migrations').
Error: ER_TABLE_EXISTS_ERR: Table 'schema_version' already exists
The table name conflicts with an existing table.
fix
Use a unique tableName or drop the conflicting table if safe.
TypeError: upgrade is not a function
Incorrect import; attempting default import or wrong require.
fix
Use named import: import { upgrade } from 'qy-mysql-upgrade'.
Upgrade
Version history
1.2.1latest on npm
Audit
Dependencies
mysql2requiredrequired for MySQL database connections
Agent activity
4 hits · last 30 days
node
4
Resources
qy-mysql-upgrade — npm install qy-mysql-upgrade · libregistry