Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

db-migrate-mysql

Package Overview
Dependencies
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

db-migrate-mysql - npm Package Compare versions

Comparing version 2.1.2 to 2.2.0

.husky/pre-commit

112

index.js

@@ -1,12 +0,12 @@

var util = require('util');
var moment = require('moment');
var mysql = require('mysql');
var Base = require('db-migrate-base');
var Promise = require('bluebird');
var log;
var type;
const util = require('util');
const moment = require('moment');
const mysql = require('mysql2');
const Base = require('db-migrate-base');
const Promise = require('bluebird');
let log;
let type;
var internals = {};
let internals = {};
var MysqlDriver = Base.extend({
const MysqlDriver = Base.extend({
init: function (connection) {

@@ -20,3 +20,3 @@ this._escapeDDL = '`';

startMigration: function (cb) {
var self = this;
const self = this;

@@ -39,3 +39,3 @@ if (!internals.notransactions) {

mapDataType: function (spec) {
var len;
let len;
switch (spec.type) {

@@ -77,5 +77,5 @@ case type.TEXT:

createColumnDef: function (name, spec, options, tableName) {
var escapedName = util.format('`%s`', name);
var t = this.mapDataType(spec);
var len;
const escapedName = util.format('`%s`', name);
const t = this.mapDataType(spec);
let len;
if (spec.type === type.DECIMAL) {

@@ -91,3 +91,3 @@ if (spec.precision && spec.scale) {

}
var constraint = this.createColumnConstraint(
const constraint = this.createColumnConstraint(
spec,

@@ -105,4 +105,4 @@ options,

createColumnConstraint: function (spec, options, tableName, columnName) {
var constraint = [];
var cb;
const constraint = [];
let cb;

@@ -155,2 +155,6 @@ if (spec.unsigned) {

if (spec.after !== undefined) {
constraint.push('AFTER ' + spec.after);
}
if (spec.comment) {

@@ -168,3 +172,7 @@ constraint.push(`COMMENT '${spec.comment}'`);

renameTable: function (tableName, newTableName, callback) {
var sql = util.format('RENAME TABLE `%s` TO `%s`', tableName, newTableName);
const sql = util.format(
'RENAME TABLE `%s` TO `%s`',
tableName,
newTableName
);
return this.runSql(sql).nodeify(callback);

@@ -200,4 +208,4 @@ },

createDatabase: function (dbName, options, callback) {
var spec = '';
var ifNotExists = '';
const spec = '';
let ifNotExists = '';

@@ -226,3 +234,3 @@ if (typeof options === 'function') callback = options;

dropDatabase: function (dbName, options, callback) {
var ifExists = '';
let ifExists = '';

@@ -241,3 +249,3 @@ if (typeof options === 'function') callback = options;

removeColumn: function (tableName, columnName, callback) {
var sql = util.format(
const sql = util.format(
'ALTER TABLE `%s` DROP COLUMN `%s`',

@@ -261,6 +269,6 @@ tableName,

var columnsList = [];
for (var columnIndex in columns) {
var column = columns[columnIndex];
var columnSpec = '';
const columnsList = [];
for (const columnIndex in columns) {
const column = columns[columnIndex];
let columnSpec = '';

@@ -280,3 +288,3 @@ if (typeof column === 'object' && column.name) {

var sql = util.format(
const sql = util.format(
'ALTER TABLE `%s` ADD %s INDEX `%s` (%s)',

@@ -312,3 +320,3 @@ tableName,

var sql = util.format('DROP INDEX `%s` ON `%s`', indexName, tableName);
const sql = util.format('DROP INDEX `%s` ON `%s`', indexName, tableName);

@@ -319,4 +327,4 @@ return this.runSql(sql).nodeify(callback);

renameColumn: function (tableName, oldColumnName, newColumnName, callback) {
var self = this;
var columnTypeSql = util.format(
const self = this;
const columnTypeSql = util.format(
"SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '%s' AND COLUMN_NAME = '%s'",

@@ -329,4 +337,4 @@ tableName,

.then(function (result) {
var columnType = result[0].COLUMN_TYPE;
var alterSql = util.format(
const columnType = result[0].COLUMN_TYPE;
const alterSql = util.format(
'ALTER TABLE `%s` CHANGE `%s` `%s` %s',

@@ -345,4 +353,4 @@ tableName,

changeColumn: function (tableName, columnName, columnSpec, callback) {
var constraint = this.createColumnDef(columnName, columnSpec);
var sql = util.format(
const constraint = this.createColumnDef(columnName, columnSpec);
const sql = util.format(
'ALTER TABLE `%s` CHANGE COLUMN `%s` %s',

@@ -354,3 +362,3 @@ tableName,

var exec = function () {
const exec = function () {
return this.runSql(sql).then(function () {

@@ -372,3 +380,3 @@ if (constraint.foreignKey) return constraint.foreignKey();

addMigrationRecord: function (name, callback) {
var formattedDate = moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
const formattedDate = moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
this.runSql(

@@ -384,3 +392,3 @@ 'INSERT INTO `' +

addSeedRecord: function (name, callback) {
var formattedDate = moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
const formattedDate = moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
this.runSql(

@@ -407,7 +415,7 @@ 'INSERT INTO `' +

}
var columns = Object.keys(fieldMapping);
var referencedColumns = columns.map(function (key) {
const columns = Object.keys(fieldMapping);
const referencedColumns = columns.map(function (key) {
return fieldMapping[key];
});
var sql = util.format(
const sql = util.format(
'ALTER TABLE `%s` ADD CONSTRAINT `%s` FOREIGN KEY (%s) REFERENCES `%s` (%s) ON DELETE %s ON UPDATE %s',

@@ -427,3 +435,3 @@ tableName,

removeForeignKey: function (tableName, keyName, options, callback) {
var sql = util.format(
let sql = util.format(
'ALTER TABLE `%s` DROP FOREIGN KEY `%s`',

@@ -457,6 +465,6 @@ tableName,

runSql: function () {
var self = this;
var args = this._makeParamArgs(arguments);
const self = this;
const args = this._makeParamArgs(arguments);
var callback = args.pop();
const callback = args.pop();
log.sql.apply(null, arguments);

@@ -477,5 +485,5 @@ if (internals.dryRun) {

_makeParamArgs: function (args) {
var params = Array.prototype.slice.call(args);
var sql = params.shift();
var callback =
let params = Array.prototype.slice.call(args);
const sql = params.shift();
const callback =
typeof params[params.length - 1] === 'function' ? params.pop() : null;

@@ -490,3 +498,3 @@

all: function () {
var args = this._makeParamArgs(arguments);
const args = this._makeParamArgs(arguments);

@@ -501,3 +509,3 @@ log.sql.apply(null, arguments);

function (resolve, reject) {
var cb = function (err, data) {
const cb = function (err, data) {
return err ? reject(err) : resolve(data);

@@ -519,3 +527,3 @@ };

exports.connect = function (config, intern, callback) {
var db;
let db;

@@ -529,5 +537,5 @@ internals = intern;

if (typeof mysql.createConnection === 'undefined') {
db = config.db || new mysql.createClient(config);
db = config.db || mysql.createClient(config);
} else {
db = config.db || new mysql.createConnection(config);
db = config.db || mysql.createConnection(config);
}

@@ -534,0 +542,0 @@

{
"name": "db-migrate-mysql",
"version": "2.1.2",
"version": "2.2.0",
"description": "db-migrate mysql driver",
"main": "index.js",
"scripts": {
"test": "lab -t 60"
"start": "node index.js",
"dev": "nodemon index.js",
"pretest": "eslint .",
"test": "lab -t 60",
"lintfix": "lint-staged",
"prepare": "husky install"
},
"husky": {
"hooks": {
"pre-commit": "npm run lintfix"
}
},
"lint-staged": {
"*.js": [
"pretty-quick --staged",
"git update-index",
"eslint --fix"
]
},
"repository": {

@@ -29,6 +46,6 @@ "type": "git",

"dependencies": {
"bluebird": "^3.2.1",
"db-migrate-base": "^2.3.1",
"moment": "^2.11.2",
"mysql": "^2.17.1"
"bluebird": "^3.7.2",
"db-migrate-base": "^2.3.0",
"moment": "^2.28.0",
"mysql2": "^2.1.0"
},

@@ -40,9 +57,14 @@ "devDependencies": {

"db-migrate-shared": "^1.1.2",
"eslint": "^6.7.2",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-node": "^10.0.0",
"eslint": "^7.1.0",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1"
"eslint-plugin-standard": "^4.0.1",
"husky": "^6.0.0",
"lint-staged": "^10.5.4",
"mysql": "^2.18.1",
"prettier": "^2.2.1",
"pretty-quick": "^3.1.0"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc