
Product
Introducing Module Reachability: Focus on the Vulnerabilities That Matter
Module Reachability filters out unreachable CVEs so you can focus on vulnerabilities that actually matter to your application.
mysql-patcher
Advanced tools
A package/program to help patch MySql databases.
This is the simplest program that can work:
var path = require('path')
var mysql = require('mysql')
var patcher = require('mysql-patcher')
var options = {
user : 'user',
database : 'db',
password : 'password',
dir : path.join(__dirname, 'schema'),
patchKey : 'schema-patch-level',
patchLevel : 4,
filePrefix : 'patch',
metaTable : 'metadata',
mysql : mysql,
}
patcher.patch(options, function(err, res) {
console.log('err:', err)
console.log('res:', res)
})
Note: you should require mysql yourself and pass this to .patch()
so that we're using the version you
want, instead of us depending on mysql ourselves.
The options are passed straight through to MySql, so you can provide any of the following:
Discussed below are some of more regular ones, but if not provided they will take the defaults specified on the mysql page (above):
Specific options for mysql-patcher
:
All patch files should be named in the following format:
<name>-<from>-<to>.sql
This example is a patch file from level 1 to level 2.
Each database patch file should perform any queries they want first, then the last statement should
set your patchKey
value (in the metaTable
) to the patch specified
Your initial patch shouldn't do much except create the metaTable
and set the patchKey
row to be 1.
If you don't know what to do, copy and paste these two files for your initial forward and reverse patches:
e.g. Forward patch file : patch-00-01.sql
CREATE TABLE metadata (
name VARCHAR(255) NOT NULL PRIMARY KEY,
value VARCHAR(255) NOT NULL
) ENGINE=InnoDB;
INSERT INTO metadata SET name = 'schema-patch-level', value = '1';
e.g. Reverse patch file : patch-01-00.sql
DROP TABLE metadata;
Once your initial patch has worked, each subsequent patch (both forward and reverse) should not try to insert the patch level, but instead update it:
e.g. Forward patch file : patch-01-02.sql
UPDATE metadata SET value = '2' WHERE name = 'schema-patch-level';
e.g. Reverse patch file : patch-02-01.sql
UPDATE metadata SET value = '1' WHERE name = 'schema-patch-level';
(Ends)
FAQs
A package/program to help patch MySql databases
The npm package mysql-patcher receives a total of 252 weekly downloads. As such, mysql-patcher popularity was classified as not popular.
We found that mysql-patcher demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Module Reachability filters out unreachable CVEs so you can focus on vulnerabilities that actually matter to your application.
Company News
Socket is bringing best-in-class reachability analysis into the platform — cutting false positives, accelerating triage, and cementing our place as the leader in software supply chain security.
Product
Socket is introducing a new way to organize repositories and apply repository-specific security policies.