npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sequelize-mig-generator

v0.2.0

Published

Streamline the management of Sequelize database schema changes with a CLI tool for generating migration files effortlessly.

Downloads

64

Readme

Sequelize Migration Generator CLI

The Sequelize Migration Generator CLI is a command-line tool designed to streamline the process of creating migration files for Sequelize-based databases. This tool helps developers manage database schema changes effectively and maintain version control for database structures.

Currently CLI supports createTable, removeTable, addColumn, modifyColumn, removeColumn migrations.

npm NPM GitHub issues CI Code Style: Google Commitizen friendly

EXAMPLE

⚠️ Disclaimer: Development Mode ⚠️

Please note that the Sequelize Migration Generator CLI is currently in development mode and should not be used in a production environment.

This tool is actively being developed and may undergo significant changes, including features, code structure, and APIs. While we encourage you to explore and test it, we strongly advise against using it in a production setting at this time.

Feel free to provide feedback, report issues, or contribute to the development efforts. Your input will be valuable in shaping the tool's stability and usability as it progresses.

Thank you for your understanding and patience as we work towards making this CLI production-ready.


Installation

Using npm:

npm i sequelize-mig-generator --save-dev

Using yarn:

yarn add sequelize-mig-generator -D

Using pnpm:

pnpm i sequelize-mig-generator -D

Getting started

  • Init sequelize-cli

    npx sequelize-cli init

    This will create following folders

    • config, contains config file, which tells CLI how to connect with database
    • models, contains all models for your project
    • migrations, contains all migration files
    • seeders, contains all seed files

read more about sequelize migrations and sequelize-cli from the official sequelize docs

  • Use sequelize-mig-generator cli

    add make:migration script to your package.json

    {
      ...
      "scripts": {
        ...
        "make:migrations": "sequelize-mig-generator -s ./models/init.js",
        "run:migrations": "sequelize-cli db:migrate"
      }
    }

    sequelize-mig-generator only needs 2 things to know:

    • sequelize path - path to sequelize init script, should have a default exported function that return a promise with the updated sequelize object. (check the example for more info.)
    • migrations folder - tell the cli where to save the generated migration files.

    Both of them are taken automatically from .sequelizerc file in case they are not set manually.

    npx sequelize-mig-generator -h
    Usage: sequelize-mig-generator [options]
    
    Streamline the management of Sequelize database schema changes with a CLI tool for generating migration files effortlessly.
    
    Options:
      -V, --version                 output the version number
      -r, --rc-path <path>          Path for your .sequelizerc file (default: ".sequelizerc")
      -e, --extension <extension>   Extensiton for your migration files (default: ".js")
      -s, --sequelize-path [path]   Path for init sequelize, models and associations (default: [models-path] key from sequelize rc file)
      -m, --migrations-path [path]  Folder to save the generated migrations (default: [migrations-path] key from sequelize rc file)
      -h, --help                    display help for command

Typescripts

Currently sequelize-path can only handle js file. So it recomended to compile your ts files and run the cli after.

example:

{
    ...
    "scripts": {
        ...
        "compile": "tsc",
        "premake:migrations": "yarn compile",
        "make:migrations": "sequelize-mig-generator -s ./dist/db/models/init.js -m ./db/migrations",
        "run:migrations": "sequelize-cli db:migrate"
    }
}

Examples

Check out our example contains an express server with sequelize on sqlite with migrations generated by the tool.