{"_id":"mysql-migrations","_rev":"11-2c8306cffd32f387255efe6d3b13aff5","name":"mysql-migrations","description":"A tool to use with mysql package to maintain migrations","dist-tags":{"latest":"1.0.7"},"versions":{"1.0.0":{"name":"mysql-migrations","version":"1.0.0","description":"A tool to use with mysql package to maintain migrations","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/kawadhiya21/node-mysql-migrations.git"},"keywords":["node","mysql","migrations","table","management"],"author":{"name":"Kshitij Awadhiya"},"license":"ISC","bugs":{"url":"https://github.com/kawadhiya21/node-mysql-migrations/issues"},"homepage":"https://github.com/kawadhiya21/node-mysql-migrations#readme","dependencies":{"mysql":"^2.13.0"},"_id":"mysql-migrations@1.0.0","_shasum":"e9a0fcc66599fd5df3499ecf7de8b142d18dcc9e","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.7.0","_npmUser":{"name":"kshitij","email":"kawadhiya21@gmail.com"},"dist":{"shasum":"e9a0fcc66599fd5df3499ecf7de8b142d18dcc9e","tarball":"https://registry.npmjs.org/mysql-migrations/-/mysql-migrations-1.0.0.tgz","integrity":"sha512-HBS7JQSPMK5qot3fAimrQFjX9Ip78WgtHGgZwJfFLPYArLfXVl9KeRoB1slPq81npra0yP3A5Ed6UhXwF/AG4g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFLp15uA/mT9f8hu0YSheBRLUVV8s3CJ0DgdXYH7bBmSAiEAv4j4jLqs6srpmAjNdjU5m61rwwmtzyqE3VSylI20Iic="}]},"maintainers":[{"name":"kshitij","email":"kawadhiya21@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/mysql-migrations-1.0.0.tgz_1488895355440_0.058592780493199825"},"directories":{}},"1.0.1":{"name":"mysql-migrations","version":"1.0.1","description":"A tool to use with mysql package to maintain migrations","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/kawadhiya21/mysql-migrations.git"},"keywords":["node","mysql","migrations","table","management"],"author":{"name":"Kshitij Awadhiya"},"license":"MIT","bugs":{"url":"https://github.com/kawadhiya21/mysql-migrations/issues"},"homepage":"https://github.com/kawadhiya21/mysql-migrations#readme","dependencies":{},"devDependencies":{"mysql":"^2.13.0"},"gitHead":"97108c7463ce142ce6ad4cbb68632eaba5100044","_id":"mysql-migrations@1.0.1","_shasum":"1c4d13040c07f1cadc57bd3b919b5aaf6b5ad6da","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.7.0","_npmUser":{"name":"kshitij","email":"kawadhiya21@gmail.com"},"dist":{"shasum":"1c4d13040c07f1cadc57bd3b919b5aaf6b5ad6da","tarball":"https://registry.npmjs.org/mysql-migrations/-/mysql-migrations-1.0.1.tgz","integrity":"sha512-ECadQO5OGHFzzsSJ2NJL0mvauBTCR3ujLCu8p7Qq+aC6GVByb2On91zrgsA1rt2qeOXpovDSDSeOmxzPGyFpaA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBlLixFmqITSdZ5wN4kZcjw309dNnGpKFotg02M2+4x1AiBZ0JUfvymPx4s2srO1i8E3iGSzl2gsLW3xqdmCUKculw=="}]},"maintainers":[{"name":"kshitij","email":"kawadhiya21@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/mysql-migrations-1.0.1.tgz_1488918734861_0.6529489455278963"},"directories":{}},"1.0.2":{"name":"mysql-migrations","version":"1.0.2","description":"A tool to use with mysql package to maintain migrations","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/kawadhiya21/mysql-migrations.git"},"keywords":["node","mysql","migrations","table","management"],"author":{"name":"Kshitij Awadhiya"},"license":"MIT","bugs":{"url":"https://github.com/kawadhiya21/mysql-migrations/issues"},"homepage":"https://github.com/kawadhiya21/mysql-migrations#readme","dependencies":{},"devDependencies":{"mysql":"^2.13.0"},"gitHead":"eb626a3f084459edaca8d0d819762c4cda70065f","_id":"mysql-migrations@1.0.2","_shasum":"7fa979d41713d356c7ad3042bb1f8e91f6df30b7","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.7.0","_npmUser":{"name":"kshitij","email":"kawadhiya21@gmail.com"},"dist":{"shasum":"7fa979d41713d356c7ad3042bb1f8e91f6df30b7","tarball":"https://registry.npmjs.org/mysql-migrations/-/mysql-migrations-1.0.2.tgz","integrity":"sha512-DqZmDK5KuRh0BYy2Eleo1Y4Z//nb81Gh4mGOqiO4uEA4yqxt8LSMztZH3S2HP/h8TyDX/FSG2JEP19FASqwqPw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIF8AUGjDVRTwXnAK++jEzzqHGFc86UJPpxck1wgIiLCWAiEA+6q4ZdW15LECDy06Zw4W8UuqMbOI8A+/YwlEPDLQ7w4="}]},"maintainers":[{"name":"kshitij","email":"kawadhiya21@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/mysql-migrations-1.0.2.tgz_1488919235340_0.9782868549227715"},"directories":{}},"1.0.3":{"name":"mysql-migrations","version":"1.0.3","description":"A tool to use with mysql package to maintain migrations","main":"index.js","scripts":{"test":"node node_modules/.bin/mocha test/*"},"repository":{"type":"git","url":"git+https://github.com/kawadhiya21/mysql-migrations.git"},"keywords":["node","mysql","migrations","table","management"],"author":{"name":"Kshitij Awadhiya"},"license":"MIT","bugs":{"url":"https://github.com/kawadhiya21/mysql-migrations/issues"},"homepage":"https://github.com/kawadhiya21/mysql-migrations#readme","dependencies":{},"devDependencies":{"chai":"^3.5.0","mocha":"^3.2.0","mysql":"^2.13.0"},"gitHead":"dcfbf668a847ce2b6748a0590f780834c22809f6","_id":"mysql-migrations@1.0.3","_shasum":"cc3708e31dcab21e952215f822d402f7821b5726","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.7.0","_npmUser":{"name":"kshitij","email":"kawadhiya21@gmail.com"},"dist":{"shasum":"cc3708e31dcab21e952215f822d402f7821b5726","tarball":"https://registry.npmjs.org/mysql-migrations/-/mysql-migrations-1.0.3.tgz","integrity":"sha512-DU7j2MwUdgz+FZVcAMlhJb2kpICTfnHRvTNV9ic1pr4yHCw2rYhgdT1F5rYol9pAL9pdyS7bQ/VvFRXWN3Fj6Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD03Gdp/0H4meEBtmhA5KoIt1uNz6s2mRK8AVhmEMuOaAIhAPxj1ayNw5mVV9AVZABqBnFwu7kyY3OdThlNsFFtyXFl"}]},"maintainers":[{"name":"kshitij","email":"kawadhiya21@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/mysql-migrations-1.0.3.tgz_1489317023806_0.23649673885665834"},"directories":{}},"1.0.4":{"name":"mysql-migrations","version":"1.0.4","description":"A tool to use with mysql package to maintain migrations","main":"index.js","scripts":{"test":"node node_modules/.bin/mocha test/*"},"repository":{"type":"git","url":"git+https://github.com/kawadhiya21/mysql-migrations.git"},"keywords":["node","mysql","migrations","table","management"],"author":{"name":"Kshitij Awadhiya"},"license":"MIT","bugs":{"url":"https://github.com/kawadhiya21/mysql-migrations/issues"},"homepage":"https://github.com/kawadhiya21/mysql-migrations#readme","dependencies":{},"devDependencies":{"chai":"^3.5.0","mocha":"^3.2.0","mysql":"^2.13.0"},"gitHead":"3deebc3ffbc56f07e8d5c5b274b11e19c54e91cf","_id":"mysql-migrations@1.0.4","_shasum":"876421807f945a965f38b39f137dba56456b0659","_from":".","_npmVersion":"2.15.5","_nodeVersion":"4.4.5","_npmUser":{"name":"kshitij","email":"kawadhiya21@gmail.com"},"dist":{"shasum":"876421807f945a965f38b39f137dba56456b0659","tarball":"https://registry.npmjs.org/mysql-migrations/-/mysql-migrations-1.0.4.tgz","integrity":"sha512-FUkQ8xiZ6w4lZWIPD//DfEKGeYD1p5GMgVvzFfE6ra9SnEqZqp0ZZIUU5m8UYs0Tyq7ojjNeg0rdI3mxI/zVPQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHOh83pTMU5lLWKwHnM4a5ez5hyAB8TyvywWwPjodxALAiANXQhBLg3aW7QEEZWcTT73tOh+nw2dByrsaVEGDXExaA=="}]},"maintainers":[{"name":"kshitij","email":"kawadhiya21@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mysql-migrations-1.0.4.tgz_1503635566640_0.08415109571069479"},"directories":{}},"1.0.5":{"name":"mysql-migrations","version":"1.0.5","description":"A tool to use with mysql package to maintain migrations","main":"index.js","scripts":{"test":"node node_modules/.bin/mocha test/*"},"repository":{"type":"git","url":"git+https://github.com/kawadhiya21/mysql-migrations.git"},"keywords":["node","mysql","migrations","table","management"],"author":{"name":"Kshitij Awadhiya"},"license":"MIT","bugs":{"url":"https://github.com/kawadhiya21/mysql-migrations/issues"},"homepage":"https://github.com/kawadhiya21/mysql-migrations#readme","dependencies":{},"devDependencies":{"chai":"^3.5.0","mocha":"^3.2.0","mysql":"^2.13.0"},"gitHead":"86fdd25761a826444f869262749fa552b6583dbb","_id":"mysql-migrations@1.0.5","_shasum":"f3ae60fccf674084668943bb91a5dac5e5e86a04","_from":".","_npmVersion":"2.15.5","_nodeVersion":"4.4.5","_npmUser":{"name":"kshitij","email":"kawadhiya21@gmail.com"},"dist":{"shasum":"f3ae60fccf674084668943bb91a5dac5e5e86a04","tarball":"https://registry.npmjs.org/mysql-migrations/-/mysql-migrations-1.0.5.tgz","fileCount":12,"unpackedSize":15975,"integrity":"sha512-uoh3qQF2+gCZIJ1QmrizZhvjmQIMcDjOtagVbCt4XtvK8RRs7KfPgvrTEVvXBUB+J9dMJrrtuBtokMkJXhnnMw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCjIEvP9Wn3+MUXzwyKCj4r8v+bmjjzF46sdhp9NDehbgIgMglOT98UXObAlpQvZh136nDxf6pxosHnS7oesX5pDG4="}]},"maintainers":[{"name":"kshitij","email":"kawadhiya21@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mysql-migrations_1.0.5_1522863447636_0.3356451559049052"},"_hasShrinkwrap":false},"1.0.6":{"name":"mysql-migrations","version":"1.0.6","description":"A tool to use with mysql package to maintain migrations","main":"index.js","scripts":{"test":"node node_modules/.bin/mocha test/*"},"repository":{"type":"git","url":"git+https://github.com/kawadhiya21/mysql-migrations.git"},"keywords":["node","mysql","migrations","table","management"],"author":{"name":"Kshitij Awadhiya"},"license":"MIT","bugs":{"url":"https://github.com/kawadhiya21/mysql-migrations/issues"},"homepage":"https://github.com/kawadhiya21/mysql-migrations#readme","dependencies":{},"devDependencies":{"chai":"^3.5.0","mocha":"^3.2.0","mysql":"^2.13.0"},"gitHead":"8aeec730363edbfda8f5c77c36c2ef346a6b1104","_id":"mysql-migrations@1.0.6","_shasum":"ec9e021127ac38460bee05178fc93d48cea0d0a4","_from":".","_npmVersion":"2.15.5","_nodeVersion":"4.4.5","_npmUser":{"name":"kshitij","email":"kawadhiya21@gmail.com"},"dist":{"shasum":"ec9e021127ac38460bee05178fc93d48cea0d0a4","tarball":"https://registry.npmjs.org/mysql-migrations/-/mysql-migrations-1.0.6.tgz","fileCount":12,"unpackedSize":15974,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa3staCRA9TVsSAnZWagAAd4IP/RLw1Gn7udDVwJlxNEy8\n0P+xcoMxu6WcDUxMofa7fM57wjNV6rwvFmwcDbYCxRaVr3oyVc8kD89kfpvv\nUEpUobtRVzERc6dmC51JNnxqhiTtwx+gH+7+tWv0x6TFya8eCFKfvavChZgb\nwzN9Isv9qf19fUE1srgnsb5QL1MWsqZPgtvpWLPJP9R0w9AANBRYiiAf8S81\nH++HXvuDDAljKzWMN7I6084wucKEmXkvjIo3MeOAwHB1I1z+pCZTmgySPPmE\nrptRuHRqy+/ko/g503yaVeaVTP3RXS+SgoVyOBZ6v9ZQRX423rh7GN1GEsM3\nQjPr4L8WMwKcfRig9cMSC75GHwGmWwhLhOY1s0woL5dgU9lj3eSZ9+BGYHuf\nef+TXSXP56VDCxAkyYQ4CYVZEFShgiiATwShQz9iRwLuHwgVXUglszAKrA5W\n9vLctIg3PTiZ2SYIqokd3e6qovWQg9DsaF85nARtPXV6ZES0lqYP3YdE1hgS\n9PUBulbST4oqPiFzsjH1/FeuhfD2cv79PPksU+nF189dH2ljEIt6+GSPCmtm\nzk8evvM76YSN+geyRPql8SOxxAkPprJ3xT4aCAu8f0V5+y7g4qw09lb5+vCd\nvEbhz0q8835iGmcSp8fDFzOhuyfXMDbKSJmEVHhb7Yo101po7PuTkilUefl2\nzXzh\r\n=XGLC\r\n-----END PGP SIGNATURE-----\r\n","integrity":"sha512-puKUmKiqrnPBVVSRZOJY2Y881ON1hEymx3kKgWeVB69JBN7QaYNctEyQpkOHy1y15sP5mGJn3C4EDwLZkmYWcQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDQUuMNnAke6onWvCBlC1T/wr0aguZIlxBIVXHyyxRYUgIhAMidULb/189mQLQqyTXLCzzWhjhmpsJ1lYDfc6HvaHJL"}]},"maintainers":[{"name":"kshitij","email":"kawadhiya21@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mysql-migrations_1.0.6_1524550488969_0.3549708660318156"},"_hasShrinkwrap":false},"1.0.7":{"name":"mysql-migrations","version":"1.0.7","description":"A tool to use with mysql package to maintain migrations","main":"index.js","scripts":{"test":"node node_modules/.bin/mocha test/*"},"repository":{"type":"git","url":"git+https://github.com/kawadhiya21/mysql-migrations.git"},"keywords":["node","mysql","migrations","table","management"],"author":{"name":"Kshitij Awadhiya"},"license":"MIT","bugs":{"url":"https://github.com/kawadhiya21/mysql-migrations/issues"},"homepage":"https://github.com/kawadhiya21/mysql-migrations#readme","dependencies":{"colors":"^1.4.0"},"devDependencies":{"chai":"^3.5.0","mocha":"^3.2.0","mysql":"^2.13.0"},"gitHead":"65c52086c766d5c91508ba66c3b811682484c4b2","_id":"mysql-migrations@1.0.7","_shasum":"20ce22de04d2ba603bf8d30b2077f863c187e1c9","_from":".","_npmVersion":"2.15.9","_nodeVersion":"4.5.0","_npmUser":{"name":"kshitij","email":"kawadhiya21@gmail.com"},"dist":{"shasum":"20ce22de04d2ba603bf8d30b2077f863c187e1c9","tarball":"https://registry.npmjs.org/mysql-migrations/-/mysql-migrations-1.0.7.tgz","integrity":"sha512-xAgKoZPwVe7liJd/U06LzS5bYIZ6lAFfhWQjxVw+c9oL9IWa63YNuV8ZYaYnSI4UJkeyhf4AClCpx+ICzzDncw==","fileCount":13,"unpackedSize":39180,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfiufwCRA9TVsSAnZWagAA8lwP/3XV+3wE5Wx4syX7+wyv\nXUFocGZc+2+YDbGvcATuIdEzIZljxEPjdBxpqrsi/ij7ETgUPuPKo589osoh\nKYZjGVp1GDfy523ZPequzBsfEekA3XWP54EJz6211y46nZT++t5gL8T7b2oi\n0+oJnRDlOz+iYCo5akBge4C8spYbr7P4MfsroK/aBlcH9HetxKOZA64qBkfn\nGCazfwy2kgokzwMqf2/yfuRS8cpICzS2q8EhHZmRKqTVfvWlg/bFYbedMS+U\nMMUtQ3tAQNfANXV13e7lkFNErTAP6LxfSSxABiKBBYk+m0G1bRePEnnOlGCL\n21B+ZtlWZRYtDBQxiLw5I27kjEJ1cA/dyIyszTCQEN0iocOcKnIPtlMEfZ8m\nc1Zq7L18ph8yHmA8WHj6s/tuNYKSEsqbovHPwyg0oi34+zO4t9BaI/ijuRZx\nr6otQvkuh9wVtkpBWicNCSTqp4jW97af+/a8/iTKCblN7tShueV93G3QgKyV\nSz62OjkfFgFOAaWFb5dRGXsBGps1sAav3rQ7zxY25w7bvFIxcCOq/bsZ1SDb\nA38tRsqHZPps0z9lrfBjTomiZL3m2437knbfyG4CBzbMipOacOHXgyYkACQg\nxsUkDSXqpZrQvRGr/nVY65dQYS7pgP2xqndQpnq+TZkEkZOaP1W59NLO1GKa\nf0RK\r\n=CYM9\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCywZzkcCz0tfwcLjN0ZgzrvBYoXbBDZhpWUOm+NecnrgIgA63dUzljTGo1NcsJ7bfBplBOcKA6Ll4lilJz6hnIlxo="}]},"maintainers":[{"name":"kshitij","email":"kawadhiya21@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mysql-migrations_1.0.7_1602938864144_0.5399929759855093"},"_hasShrinkwrap":false}},"readme":"# mysql-migrations\n\n## Table of contents\n - [Prerequisites](#prerequisites)\n - [Install](#install)\n - [Setup](#setup)\n - [Adding Migrations](#adding-migrations)\n - [Executing Migrations](#executing-migrations)\n\n## Prerequisites\nA node project with [mysql](https://github.com/mysqljs/mysql) used for database.\n\n## Install\nIt can be installed using npm.\n\n```\nnpm install mysql-migrations\n```\n\n## Setup\n1. Create a directory where you wish to maintain all your migrations. We call it `migrations`.\n2. Instantiate mysql-migrations by passing a mysql pool and the migrations directory path.\n\n```\n# migration.js\nvar mysql = require('mysql');\nvar migration = require('mysql-migrations');\n\nvar connection = mysql.createPool({\n  connectionLimit : 10,\n  host     : 'localhost',\n  user     : 'root',\n  password : 'password',\n  database : 'your_database'\n});\n\nmigration.init(connection, __dirname + '/migrations');\n```\n\n### Advanced Setup\nIf you want to execute something at the end of any migration, you can add third parameter as callback function. Example:\n\n```\n# migration.js\nvar mysql = require('mysql');\nvar migration = require('mysql-migrations');\n\nvar connection = mysql.createPool({\n  connectionLimit : 10,\n  host     : 'localhost',\n  user     : 'root',\n  password : 'password',\n  database : 'your_database'\n});\n\nmigration.init(connection, __dirname + '/migrations', function() {\n  console.log(\"finished running migrations\");\n});\n```\n\n## Adding Migrations\n\n### Initiate a migration\nRun\n\n```\nnode migration.js add migration create_table_users\n```\n\nNow open the migrations folder. Locate the newest file with greatest timestamp as it predecessor. The file will have the name which was specified in the command such as `12213545345_create_table_users.js`\n\n### Add migrations\nWrite the query in `up` key of the json created for the forward migration. As a part of good practice, also write the script to rollback the migration in `down` key. Ex.\n\n```\nmodule.exports = {\n    \"up\": \"CREATE TABLE users (user_id INT NOT NULL, UNIQUE KEY user_id (user_id), name TEXT )\",\n    \"down\": \"DROP TABLE users\"\n}\n```\n\n### Add seed\nRun\n```\nnode migration.js add seed create_table_users\n```\nto add a seed.\n\n```\nmodule.exports = {\n    \"up\": \"UPDATE users SET name = 'John Snow' WHERE name = ''\",\n    \"down\": \"UPDATE users SET name = '' WHERE name = 'John Snow'\"\n}\n```\n\n### Initate and Add migration in single command\n\nRun\n```\nnode migration.js add migration create_table_users \"CREATE TABLE mysql_migrations_347ertt3e (user_id INT NOT NULL, UNIQUE KEY user_id (user_id) )\"\n```\nLocate the newest file with greatest timestamp as it predecessor and open it. Query will be automatically added as `up` key. However `down` key needs to be filled manually.\n\n### Custom migrations\nYou may initiate the migration file and add a function.\n\n```\nmodule.exports = {\n  'up' :  function (conn, cb) {\n    conn.query (\"UPDATE users set name = 'alen'\", function (err, res) {\n      cb();\n    });\n  },\n  'down' : \"\"\n}\n```\n\n## Executing Migrations\nThere are few ways to run migrations.\n\n1. Run `node migration.js up`. Runs all the pending `up` migrations.\n2. Run `node migration.js up 2`. Runs 2 pending `up` migrations from the last position.\n3. Run `node migration.js down`. Runs only 1 `down` migrations.\n4. Run `node migration.js refresh`. Runs all down migrations followed by all up.\n\nExample Output:\n\n```\nUP: \"CREATE TABLE users2 (user_id INT NOT NULL, UNIQUE KEY user_id (user_id), name TEXT )\"\nUP: \"CREATE TABLE users (user_id INT NOT NULL, UNIQUE KEY user_id (user_id), name TEXT )\"\nUP: \"CREATE TABLE users1 (user_id INT NOT NULL, UNIQUE KEY user_id (user_id), name TEXT )\"\nNo more \"UP\" migrations to run\n```\n\n### Execute anonymous migrations\nAt times, few migrations need to run again or anonymously. There could be variety of reasons old migrations need to be executed or rollbacked. It can be done this way.\n\n**Up migration**\n```\nnode migration.js run 1500891087394_create_table_users.js up\n```\n\n**Down migration**\n```\nnode migration.js run 1500891087394_create_table_users.js down\n```\n\n>> Since these are anonymous executions, no records are maintained for any executions.\n\n## Executing backdated migrations\nSuppose there are few migrations which were merged late into the main branch. Technically, they should not run because they are old migrations and should already have been run, but it happens that someone has been working on a branch for long and once merged into master, the older migrations do not work because the latest migration timestamp is greater. There is a flag which can help in running those migrations. There are two ways:\n1. Single Run\n```\nnode migration.js up --migrate-all\n```\n2. For all runs, you can configure in the init part itself.\n```\n# migration.js\nvar mysql = require('mysql');\nvar migration = require('mysql-migrations');\n\nvar connection = mysql.createPool({\n  connectionLimit : 10,\n  host     : 'localhost',\n  user     : 'root',\n  password : 'password',\n  database : 'your_database'\n});\n\nmigration.init(connection, __dirname + '/migrations', function() {}, [\"--migrate-all\"]);\n```\nand then run migrations normally\n\n```\nnode migration.js up\n```\n\n## Saving Schema and Loading from Schema\nHaving schema.sql is good because it will help you review the schema changes in PR itself. The schema is stored in migrations folder under the file name `schema.sql`. There are two ways to generate schema.\n1. Single Run\n```\nnode migration.js up --update-schema\n```\n2. For all runs, you can configure in the init part itself.\n```\n# migration.js\nvar mysql = require('mysql');\nvar migration = require('mysql-migrations');\n\nvar connection = mysql.createPool({\n  connectionLimit : 10,\n  host     : 'localhost',\n  user     : 'root',\n  password : 'password',\n  database : 'your_database'\n});\n\nmigration.init(connection, __dirname + '/migrations', function() {}, [\"--update-schema\"]);\n```\nand then run migrations normally\n\n```\nnode migration.js up\nnode migration.js down 2\n..\n```\n\nUpdated Schema will be stored in migrations folder after each run.\n\n### Loading Directly from Schema\nSuppose you setup your project and you want to avoid running the entire migrations and simply want to load it from schema generated in the above process. You can do it via:\n\n```\nnode migration.js load-from-schema\n```\n\nThe above command will create all the tables and make entry in the logs table. It is helpful when setting up projects for newbies or environments without running entire migration process.\n\n## Pending\n>>Test cases: Will pick up when I get time.\n\n## Help and Support\nWill be more than happy to improve upon this version. This is an over night build and needs to be improved certainly. Will welcome everyone who wants to contribute.\n\n## Credits and other stuff\nIt is my first contribution to npm and I am sort of happy over it. I made this when I was really looking for a suitable tool with barebone settings allowing me to maintain database structure. I could not find a basic one and hence wrote my own and finally decided to publish. It took me around 2 hours to write the first version which barely works. But it still does my job.\n\n>>Credits to my parents.\n\n","maintainers":[{"name":"kshitij","email":"kawadhiya21@gmail.com"}],"time":{"modified":"2022-06-20T18:12:49.601Z","created":"2017-03-07T14:02:36.111Z","1.0.0":"2017-03-07T14:02:36.111Z","1.0.1":"2017-03-07T20:32:16.892Z","1.0.2":"2017-03-07T20:40:35.896Z","1.0.3":"2017-03-12T11:10:24.454Z","1.0.4":"2017-08-25T04:32:46.716Z","1.0.5":"2018-04-04T17:37:27.719Z","1.0.6":"2018-04-24T06:14:49.083Z","1.0.7":"2020-10-17T12:47:44.326Z"},"homepage":"https://github.com/kawadhiya21/mysql-migrations#readme","keywords":["node","mysql","migrations","table","management"],"repository":{"type":"git","url":"git+https://github.com/kawadhiya21/mysql-migrations.git"},"author":{"name":"Kshitij Awadhiya"},"bugs":{"url":"https://github.com/kawadhiya21/mysql-migrations/issues"},"license":"MIT","readmeFilename":"README.MD"}