{"id":25417393,"url":"https://github.com/2020leon/typeorm-migrate-sql","last_synced_at":"2025-10-31T09:31:16.019Z","repository":{"id":54483430,"uuid":"519138779","full_name":"2020leon/typeorm-migrate-sql","owner":"2020leon","description":"Generate Sql Files and Migrate","archived":false,"fork":false,"pushed_at":"2023-02-14T15:10:06.000Z","size":85,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-14T14:11:58.222Z","etag":null,"topics":["database","javascript","mariadb","migration","migration-tool","migrations","mysql","node","nodejs","npm","npm-cli","npm-package","sql","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/2020leon.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-29T08:26:45.000Z","updated_at":"2024-03-01T10:45:00.000Z","dependencies_parsed_at":"2024-11-14T13:22:18.089Z","dependency_job_id":"87807cb7-a61e-4687-8e6c-bda107bf417d","html_url":"https://github.com/2020leon/typeorm-migrate-sql","commit_stats":{"total_commits":17,"total_committers":1,"mean_commits":17.0,"dds":0.0,"last_synced_commit":"267e565da6851bc41123262f54921b1095f2d97b"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2020leon%2Ftypeorm-migrate-sql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2020leon%2Ftypeorm-migrate-sql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2020leon%2Ftypeorm-migrate-sql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2020leon%2Ftypeorm-migrate-sql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/2020leon","download_url":"https://codeload.github.com/2020leon/typeorm-migrate-sql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239120205,"owners_count":19584980,"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":["database","javascript","mariadb","migration","migration-tool","migrations","mysql","node","nodejs","npm","npm-cli","npm-package","sql","typescript"],"created_at":"2025-02-16T17:39:10.112Z","updated_at":"2025-10-31T09:31:10.702Z","avatar_url":"https://github.com/2020leon.png","language":"TypeScript","readme":"# Typeorm Migrate Sql\n\nTypeorm Migrate Sql - Generate Sql Files and Migrate\n\nTypeorm Migrate Sql is a package that can generate new migrations in sql format\nand runs those generated migrations.\n\n## Supported Databases\n\n- MySQL\n- MariaDB\n\n## Requirements\n\n| Engine/Package         | Version          | Optional |\n|------------------------|------------------|----------|\n| Node.js                | \u003e=14             |          |\n| [TypeORM][typeorm]     | ^0.3.12          |          |\n| [Node MySQL 2][mysql2] | ^2.2.5 or ^3.0.1 |          |\n| [ts-node][ts-node]     | ^10.7.0          | true     |\n\n## Installation\n\nYou can install Typeorm Migrate Sql using `npm`, `yarn`, or `pnpm`.\n\n```sh\n# npm\nnpm i typeorm-migrate-sql\n# yarn\nyarn add typeorm-migrate-sql\n# pnpm\npnpm add typeorm-migrate-sql\n```\n\n## Usage\n\n### CLI\n\nRunning our command via `npx`.\n\n```sh\nnpx typeorm-migrate-sql help\n```\n\nWe recommend that you add the following to `package.json` for convenience.\n\n```json\n{\n  \"scripts\": {\n    \"migrate\": \"typeorm-migrate-sql\"\n  }\n}\n```\n\nThen you may run the command like following.\n\n```sh\nnpm run migrate -- help\n```\n\n#### Create a Set of Up/Down Migrations\n\n```sh\nnpx typeorm-migrate-sql create add_user\n```\n\nThe command creates two empty files called `\u003ctimestamp\u003e_add_user.up.sql` and\n`\u003ctimestamp\u003e_add_user.down.sql` in directory `db/migrations`. You can specify\nthe directory via cli options.\n\n#### Generate a Set of Up/Down Migrations\n\n```sh\nnpx typeorm-migrate-sql generate my_schema add_user\n```\n\nAfter modifying typeorm entities, you can run this command to generate two sql\nfiles called `\u003ctimestamp\u003e_add_user.up.sql` and `\u003ctimestamp\u003e_add_user.down.sql`\nin directory `db/migrations`. You can set connection options, location of\nentities, and the output directory via cli options.\n\n#### Get Current Migration Version\n\n```sh\nnpx typeorm-migrate-sql version my_schema\n```\n\nThe command gets current migration version recorded in the database. Connection\nand some other options can be set via cli options. If you have never migrated\nthe database before or the name of migration table is wrong, the version will\nnot be found or defined.\n\n#### Run Migrations\n\n```sh\n# run either one\nnpx typeorm-migrate-sql up my_schema\nnpx typeorm-migrate-sql down my_schema\nnpx typeorm-migrate-sql goto my_schema 1637690400000\n```\n\nThese commands run migrations to a version. `up` applies an up migration, `down`\napplies a down migration, while `goto` migrates to the specific version.\nSimilarly, options can be set via cli. Note that if the last migration failed,\nthese commands will also fail.\n\n## Inspiration\n\nThe package is inspired by [golang-migrate][golang-migrate].\n\n## Contributing\n\nContributing is welcome!\n\n## License\n\nMIT\n\n## Links\n\n[GitHub](https://github.com/2020leon/typeorm-migrate-sql),\n[npm](https://www.npmjs.com/package/typeorm-migrate-sql),\n[yarn](https://yarnpkg.com/package/typeorm-migrate-sql)\n\n[typeorm]: https://github.com/typeorm/typeorm\n[mysql2]: https://github.com/sidorares/node-mysql2\n[ts-node]: https://github.com/TypeStrong/ts-node\n[golang-migrate]: https://github.com/golang-migrate/migrate\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2020leon%2Ftypeorm-migrate-sql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F2020leon%2Ftypeorm-migrate-sql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2020leon%2Ftypeorm-migrate-sql/lists"}