Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
node-mini-migrations
Advanced tools
A very small, lightweight and flexible migrations library unconcerned with what database you use
A really simple node migrations library that is completely independant of any database or file system.
You need to define a driver for example:
npm install node-mini-migrations
# migrations/driver.js
const fs = require('fs')
// `passedFunctions` are passed to each migration file and can container
// a database, like mysql, postgres, mongodb, or anything you want.
// It just returns an object that gets passed to migrations.
const passedFunctions = {
tableCreate: (table) => {
console.log('would create a table', table)
},
tableDrop: (table) => {
console.log('would drop a table', table)
},
insert: (row) => {
console.log('would insert a row', row)
},
remove: (row) => {
console.log('would remove a row', row)
}
}
module.exports = {
init: () => {
if (!fs.existsSync('test_state.json')) {
fs.writeFileSync('test_state.json', JSON.stringify({}))
}
},
finish: () => {
console.log('finished migrations')
},
getMigrationState: (id) => {
const state = JSON.parse(
fs.readFileSync('test_state.json', 'utf8')
)
return state[id]
},
setMigrationUp: (id) => {
const state = JSON.parse(
fs.readFileSync('test_state.json', 'utf8')
)
state[id] = true
fs.writeFileSync('test_state.json', JSON.stringify(state))
},
setMigrationDown: (id) => {
const state = JSON.parse(
fs.readFileSync('test_state.json', 'utf8')
)
delete state[id]
fs.writeFileSync('test_state.json', JSON.stringify(state))
},
getPassedFunctions: () => passedFunctions
}
You can then create typical migrations files like:
# migrations/1-my-migration-example.js
module.exports = {
up: db => {
return db.tableCreate('test_table')
},
down: db => {
return db.tableDrop('test_table')
}
}
You run migrator up
to bring up any migrations or migrator down
to bring them down.
const {up, prepareRun} = require('node-mini-migrations')
up(prepareRun('./migrations'))
This project is licensed under the terms of the GPLv3 license.
FAQs
A very small, lightweight and flexible migrations library unconcerned with what database you use
The npm package node-mini-migrations receives a total of 11 weekly downloads. As such, node-mini-migrations popularity was classified as not popular.
We found that node-mini-migrations demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.