https://github.com/primetime/node-mysql-upgrade
A simple MySQL database upgrade module based on plain SQL files
https://github.com/primetime/node-mysql-upgrade
database mysql nodejs sql
Last synced: about 2 months ago
JSON representation
A simple MySQL database upgrade module based on plain SQL files
- Host: GitHub
- URL: https://github.com/primetime/node-mysql-upgrade
- Owner: primetime
- License: mit
- Created: 2017-04-19T14:59:04.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2024-05-30T20:45:30.000Z (about 2 years ago)
- Last Synced: 2025-09-20T04:41:37.855Z (9 months ago)
- Topics: database, mysql, nodejs, sql
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/mysql-upgrade
- Size: 9.77 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# MySQL Upgrade
[](https://www.npmjs.com/package/mysql-upgrade)
A simple MySQL database upgrade module based on plain SQL files. For developers who don't use an ORM like Sequelize, but still want to have a `database.sync();` functionality.
```
npm install --save mysql-upgrade
```
## Requirements
This module only works with Node 7.6 or later (because of native support for `async/await`).
## How to use
```Javascript
const upgrade = require('mysql-upgrade')
const upgradeConfig = {
// MySQL settings (passed directly to the MySQL connector) - at least user, password and database are required
mysql: {
host: 'localhost',
user: 'root',
password: '',
database: ''
},
// Enable or disable logging output of the module
// Optional, default: false
verbose: true,
// Name of the table that will store the database version
// Optional, default: '_upgrade_version'
// Set this if you already have a table '_upgrade_version' to avoid clashing
table: 'my_upgrade_version',
// Path where the SQL files are located
// Optional, default: './database'
path: './my-sql-files'
};
upgrade(upgradeConfig).then(function(upgraded) {
console.log(upgraded);
// { oldVersion: 0, newVersion: 1 }
})
```
## Issues
If you encounter any bugs or problems with this module, please [sumit an issue](https://github.com/primetime/node-mysql-upgrade/issues). Pull requests with bugfixes are of course welcome.