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

typeorm-migrate-sql

v0.0.2

Published

Generate Sql Files and Migrate

Downloads

10

Readme

Typeorm Migrate Sql

Typeorm Migrate Sql - Generate Sql Files and Migrate

Typeorm Migrate Sql is a package that can generate new migrations in sql format and runs those generated migrations.

Supported Databases

  • MySQL
  • MariaDB

Requirements

| Engine/Package | Version | Optional | |------------------------|------------------|----------| | Node.js | >=14 | | | TypeORM | ^0.3.12 | | | Node MySQL 2 | ^2.2.5 or ^3.0.1 | | | ts-node | ^10.7.0 | true |

Installation

You can install Typeorm Migrate Sql using npm, yarn, or pnpm.

# npm
npm i typeorm-migrate-sql
# yarn
yarn add typeorm-migrate-sql
# pnpm
pnpm add typeorm-migrate-sql

Usage

CLI

Running our command via npx.

npx typeorm-migrate-sql help

We recommend that you add the following to package.json for convenience.

{
  "scripts": {
    "migrate": "typeorm-migrate-sql"
  }
}

Then you may run the command like following.

npm run migrate -- help

Create a Set of Up/Down Migrations

npx typeorm-migrate-sql create add_user

The command creates two empty files called <timestamp>_add_user.up.sql and <timestamp>_add_user.down.sql in directory db/migrations. You can specify the directory via cli options.

Generate a Set of Up/Down Migrations

npx typeorm-migrate-sql generate my_schema add_user

After modifying typeorm entities, you can run this command to generate two sql files called <timestamp>_add_user.up.sql and <timestamp>_add_user.down.sql in directory db/migrations. You can set connection options, location of entities, and the output directory via cli options.

Get Current Migration Version

npx typeorm-migrate-sql version my_schema

The command gets current migration version recorded in the database. Connection and some other options can be set via cli options. If you have never migrated the database before or the name of migration table is wrong, the version will not be found or defined.

Run Migrations

# run either one
npx typeorm-migrate-sql up my_schema
npx typeorm-migrate-sql down my_schema
npx typeorm-migrate-sql goto my_schema 1637690400000

These commands run migrations to a version. up applies an up migration, down applies a down migration, while goto migrates to the specific version. Similarly, options can be set via cli. Note that if the last migration failed, these commands will also fail.

Inspiration

The package is inspired by golang-migrate.

Contributing

Contributing is welcome!

License

MIT

Links

GitHub, npm, yarn