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

sequelizemm

v1.3.0

Published

Sequelize Migration script generator using interactive cli

Downloads

884

Readme

Sequelize Make Migration

Sequelize Make Migration is a command-line interface tool that simplifies the creation and management of migrations for your Sequelize project. This tool utilizes the Query Interface provided by Sequelize to create migration files that can be used to modify your database schema.

Installation

To install the library globally, run the following command:

npm i -g sequelizemm

Getting Started

Before you can use sequelizemm, you need to set up your Sequelize instance. To do this, create a file called sequelize.js in the root directory of your application, and then initialize your models and associations.

Here's an example of what your sequelize.js file might look like:

const { Sequelize } = require("sequelize")

const sequelize = new Sequelize(/* options go here */)

// initialize models and associations here
// ...

module.exports.sequelize = sequelize

Note: If you have exported the Sequelize instance from a file with a different name or path, you can specify the path to that file and the exported name using the --file and --name command-line arguments, respectively. See the Command-line Arguments section for more information.

Creating Migrations

To create a new migration file, run the following command in your terminal:

sequelizemm

This will open an interactive prompt that will guide you through creating the migration. You will be asked to provide details such as the name of the migration and the changes you want to make to your models.

Once you have completed the prompts, sequelizemm will create a new migration file in your project's migrations directory. This file will contain the necessary Query Interface code to make the changes you specified.

In addition to creating the migration file, sequelizemm will also create a schema.json file in your project's root directory. This file contains the current details of your Sequelize models and will be used to detect changes in your model structure for future migrations. Do not delete this file.

Programmatic Use

You can also import the makemigration function and use it programmatically in your application. Here's an example of what your code might look like:

const { makemigration } = require("sequelizemm")

makemigration(sequelize, schema)

Note: The schema parameter is optional. If you don't provide a schema, a new migration will be generated.

Command-line Arguments

You can use the following command-line arguments with sequelizemm:

  • --file or -f: Path to a file that exports the Sequelize instance (default: sequelize.js). Example: sequelizemm --file path/to/my/sequelize.js
  • --name or -n: Name of the exported Sequelize instance (default: sequelize). Example: sequelizemm --name mySequelize
  • --help or -h: Display help message. Example: sequelizemm --help

Note: All command-line arguments are optional.

Features

  • Support Sequelize v6 & v7
  • Synchronize database with current models
  • Generate up and down migrations
  • Follow Sequelize migration naming strategy
  • Add constraints automatically
  • Support ESM and CJS
  • Perform migration using transaction

License

MIT

Copyright (c) 2033-present, Md Hashinur Rahman