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

blkswan

v1.0.7

Published

MySQL migration generator

Downloads

14

Readme

NPM package for easy migrations using mysql.

Features

  • Provide easy command line migration file generation
  • MySql syntax mapper for migration files
  • Auto migrations for migrating: up, all, down, and reset
  • Migration tracker for keeping track of migration

Install

Make sure blkswan is installed globally

$ sudo npm install -g blkswan

Run all commands from the root directory of your project

Ensure mysql package is installed for acessing the database

$ npm install mysql

Setup

This step is optional. It will setup a migrations folder and add config files to your .gitignore.

$ blkswan migrate:setup

Now go into migrations/db.conf.js and enter config variables.

Install

$ blkswan migrate:install

This will add a migrations table to your database

Create migrations

$ blkswan migrate:create migration_name

This will create a file in your migrations directory with boilerplate code

-- Or --

$ blkswan migrate:create create_users_books_table

This will create code for creating a users_books table

You can also give params

$ blkswan migrate:create create_book_table name author --int=num_pages publisher --int=year_published

Running migrations

Running all migrations is default behaviour

$ blkswan migrate

Other options include

$ blkswan migrate:one
$ blkswan migrate:reset
$ blkswan migrate:down

One: migrates the next single migration

Reset: rolls back all migrations

Down: rolls back the last migration

Migration Files

Map json objects to mysql queries

Creating a table

General syntax

exports.up = {
	"table_name":{
		"id":{"type":"increments"},
		"email":{"type":"string", "null":false, "length":"10"},
		"level":{"type":"double", "default":"1.618"}, 
		"exact_level":{"type":"double", "length":"9", "decimal":"4"},
		"my_index":{"type":"index", "column":"level"},
		"created_at":{"type":"timestamp","time":"NOW"}
	}
}
Available types
  • String or String defaults to length of 256
  • Increments: creates a auto incrmenting table with a primary id
  • Int or Integer defaults to length of 10
  • Small one digit int
  • Longtext
  • Datetime
  • Timestamp
  • Date
  • Double with length and decimal params defaults to double(7,4)
  • Index
Other params
  • "Unsigned":true
  • "Null":false
  • "Default":"blkswan"
  • "Unique":true
  • "Unsighed":true

Drop table syntax

exports.down = {"drop":"table_name"}