{"id":18037563,"url":"https://github.com/jeremija/node-sqlmigrate","last_synced_at":"2025-04-05T00:23:00.176Z","repository":{"id":57368385,"uuid":"51597838","full_name":"jeremija/node-sqlmigrate","owner":"jeremija","description":"Helps automating MySQL migrations written in plain .sql scripts","archived":false,"fork":false,"pushed_at":"2019-03-06T21:01:56.000Z","size":38,"stargazers_count":0,"open_issues_count":3,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-10T08:44:30.750Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jeremija.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-12T15:42:31.000Z","updated_at":"2016-02-12T15:42:45.000Z","dependencies_parsed_at":"2022-09-05T19:21:32.699Z","dependency_job_id":null,"html_url":"https://github.com/jeremija/node-sqlmigrate","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeremija%2Fnode-sqlmigrate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeremija%2Fnode-sqlmigrate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeremija%2Fnode-sqlmigrate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeremija%2Fnode-sqlmigrate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeremija","download_url":"https://codeload.github.com/jeremija/node-sqlmigrate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247267588,"owners_count":20911008,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-30T13:12:31.627Z","updated_at":"2025-04-05T00:23:00.158Z","avatar_url":"https://github.com/jeremija.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sqlmigrate\n\n[![Build Status](https://travis-ci.org/jeremija/node-sqlmigrate.svg?branch=master)](https://travis-ci.org/jeremija/node-sqlmigrate)\n\nHelps automating MySQL migrations written in plain `.sql` scripts.\n\n**Note:** The CLI utility API has changed in v2.\n\n# Usage\n\n## Library\n\n```javascript\nrequire('sqlmigrate').create({\n  migrationsDir: 'db/migrations',\n  dbConfig: {\n    database: 'sqlmigrate_test',\n    host: '127.0.0.1',\n    port: 3306,\n    user: 'travis',\n    password: ''\n  }\n})\n.migrate();\n```\n\n## CLI\n\n`sqlmigrate` script will attempt to read the config file from the current\nworking directory named `.sqlmigrate`:\n\n```javascript\n// .sqlmigrate example\nmodule.exports = {\n  migrationsDir: 'src/db/migrations',\n  dbConfig: {\n    database: process.env.DB_NAME,\n    host: process.env.DB_HOST,\n    port: process.env.DB_PORT,\n    user: process.env.DB_USER,\n    password: process.env.DB_PASS\n  }\n};\n```\n\nIf `driver` property is specified in the config file, it can be used to select\nthe database client. For example, this is how [mysql2][mysql2] can be used:\n\n```javascript\nmodule.exports = {\n  migrationsDir: 'src/db/migrations',\n  driver: 'mysql2',\n  dbConfig: {...}\n}\n```\n\n### Installation\n\n```bash\n$ npm install sqlmigrate\n$ export PATH=\"$(PWD)/node_modules/.bin:$(PATH)\"\n\n# or\n\n$ npm install -g sqlmigrate\n```\n\n### CLI help\n\n```bash\n$ sqlmigrate --help\n\nUsage: sqlmigrate [command] [args...]\n\nMigration will be performed when no command is specified.\n\nThe default command accepts the following optional args:\n\n  --config=file  config file to use, default is .sqlmigrate\n  --max=n        max number of migrations to perform\n  --any-order    do not fail if there are new migrations\n                 created before the last executed migration\n\nCommands:\n  create [--name=string]  creates a migration\n  help                    prints this help\n  init                    initialize config file\n```\n\n### Initize config\n\n```bash\n$ sqlmigrate init [--config=/path/to/file]\n```\n\n### Creating a migration script\n\n```bash\n$ sqlmigrate create --name='new-migration' [--config=/path/to/file]\n```\n\n### Execute migrations\n\n```bash\n$ sqlmigrate [--config=/path/to/file]\n```\n\n### Execute first two migrations\n\n```bash\n$ sqlmigrate --max=2\n```\n\n### Perform the migrations, ignoring the order of currently executed migrations\n\n```bash\n$ sqlmigrate --any-order\n```\n\n# License\n\n[MIT](LICENSE)\n\n[mysql2]: https://www.npmjs.com/package/mysql2\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeremija%2Fnode-sqlmigrate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeremija%2Fnode-sqlmigrate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeremija%2Fnode-sqlmigrate/lists"}