ts-mig
v1.0.2
Published
Sequelize migration genarator for typescript
Downloads
25
Maintainers
Readme
This package is designed to address the issue of generating migrations using the Sequelize CLI in a TypeScript-based project that utilizes Sequelize.
Sequelize is an ORM (Object-Relational Mapping) library for Node.js that provides easy database access and management. Sequelize migrations are used to manage changes in the database schema over time, allowing developers to make alterations without losing existing data. However, using Sequelize with TypeScript can sometimes present challenges when generating migrations through the Sequelize CLI.
The "typescript-sequelize-migration" package aims to simplify this process by providing a solution specifically tailored for TypeScript-based projects using Sequelize. It likely includes custom functionality or modifications to the Sequelize CLI to ensure seamless migration generation and TypeScript integration.
I personally had tested this npm package with Nestjs and typescript and expressjs based project
Note: ct: Create Table
#local installation
npm i --save-dev ts-mig
#Global installation
npm i -g ts-mig
# create a sequelized based migration
$ ts-mig
# create a sequelized based migration named migration
$ ts-mig -n="{migration file name}"
# create a sequelized based migration named migration
$ ts-mig -f="{filepath}"
#another easy way to create npm script
#copy paste below line in npm scripts
"create-migration": " ts-mig -f src/db/migrations"
→ Sequelize-cli
→ Sequelize
Steps:
- Create a .sequelizerc file with following content const path = require('path');
- Run Command
- Configure command in npm script, add following lines in
run command directly form to create migration file with default file name.
or run command directly form to create migration file and provide file name.