larvitdbmigration
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -134,2 +134,27 @@ 'use strict'; | ||
// Update old version of table (for seamless updating of old versions of this module) | ||
tasks.push(function(cb) { | ||
db.query('DESCRIBE `' + options.tableName + '`', function(err, rows) { | ||
if (err) { | ||
cb(err); | ||
return; | ||
} | ||
if (rows.length === 2 && rows[0].Field === 'version' && rows[1].Field === 'running') { | ||
// Old version detected! Update! | ||
db.query('ALTER TABLE `' + options.tableName + '` ADD `id` tinyint(1) unsigned NOT NULL DEFAULT \'1\' FIRST;', function(err) { | ||
if (err) { | ||
cb(err); | ||
return; | ||
} | ||
db.query('ALTER TABLE `' + options.tableName + '` ADD PRIMARY KEY `id` (`id`);', cb); | ||
}); | ||
} else { | ||
// Nothing to do, continue | ||
cb(); | ||
} | ||
}); | ||
}); | ||
// Insert first record if it does not exist | ||
@@ -136,0 +161,0 @@ tasks.push(function(cb) { |
@@ -33,3 +33,3 @@ { | ||
}, | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"readmeFilename": "README.md", | ||
@@ -36,0 +36,0 @@ "scripts": {}, |
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
9368
157