Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
larvitdbmigration
Advanced tools
This is used to keep track of the database structure, and update it when need be via deploys.
At the moment only MariaDB(/MySQL) is supported.
A table by default called db_version will be created, containing a single integer.
Scripts will be placed by default in process.cwd()/dbmigration/.js
Each migration script will be ran, and the db_version increased, until no more migration scripts exists.
In your application startup script, do something like this:
'use strict';
const dbMigration = require('larvitdbmigration');
dbMigration({
'host': '127.0.0.1',
'user': 'foo',
'password': 'bar',
'database': 'baz'
})(function(err) {
if (err) {
throw err;
}
// Now database is migrated and ready for use!
});
If larvitdb already is initiated someplace else, you can omit the database config, like this:
const dbMigration = require('larvitdbmigration'),
db = require('larvitdb');
db.setup({
'host': '127.0.0.1',
'user': 'foo',
'password': 'bar',
'database': 'baz'
});
dbMigration()(function(err) {
if (err) {
throw err;
}
// Now database is migrated and ready for use!
});
To use custom table name and/or script path, just change
dbMigration({
'host': '127.0.0.1',
'user': 'bar',
'password': 'bar',
'database': 'bar'
})(function(err) {
to
dbMigration({
'host': '127.0.0.1',
'user': 'bar',
'password': 'bar',
'database': 'bar',
'tableName': 'db_version',
'migrationScriptsPath': './dbmigration'
})(function(err) {
Lets say the current database have a table like this:
CREATE TABLE bloj (nisse int(11));
And in the next deploy we'd like to change the column name "nisse" to "hasse". For this you can do one of two methods:
Create the file process.cwd()/migrationScriptsPath/1.js with this content:
'use strict';
const db = require('db');
exports = module.exports = function(cb) {
db.query('ALTER TABLE bloj CHANGE nisse hasse int(11);', cb);
};
IMPORTANT! SQL files will be ignored if a .js file exists.
Create the file process.cwd()/migrationScriptsPath/1.sql with this content:
ALTER TABLE bloj CHANGE nisse hasse int(11);
Tadaaa! Now this gets done once and the version will be bumped to 1. If you then create a script named "2.js" or "2.sql" you might guess what happends. :)
FAQs
node.js database migration tool
The npm package larvitdbmigration receives a total of 174 weekly downloads. As such, larvitdbmigration popularity was classified as not popular.
We found that larvitdbmigration demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.