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

sqlv

v1.2.0

Published

Very simple SQL Migrator.

Downloads

16

Readme

SQLV

Build Downloads Version License

dependencies Status devDependencies Status

NPM

Let SQL do what SQL can.

SQLV is very simple SQL Migrator.

SQLV Image

Installation

$ npm i sqlv -D

Change the package.json file to the following:

{
  "scripts": {
    "sqlv": "sqlv"
  },
  ...
}

Now, Type the following to print the version.

$ npm run sqlv --version

To use it globally, please do the following:

$ npm i sqlv -g

Usage

Initialize Project

$ sqlv init .
$ sqlv init yourprojectpath

This will create a configuration file, sqlv.config.js.

You need to install additional packages(mysql, mysql2, pg, sqlite3) to match your database. SQLV is based on the @stdjs/database.

example,

$ npm i mysql
$ npm i mysql2
$ npm i pg
$ npm i sqlite3

Now, edit sqlv.config.js file as follows:

module.exports = {
  adapter: "mysql2",
  host: "localhost",
  database: "test",
  user: "root",
  password: "********",
}

Create Migrations

$ sqlv create create_init_tables

Two files(181201_000000_create_init_tables.up.sql, 181201_000000_create_init_tables.down.sql) are created under the ./migrations directory.

Migrate

$ sqlv migrate
up 181201_000000 ... OK

Show Current Status

SQLV Image

$ sqlv status

Rollback

$ sqlv rollback
down 181201_000000 ... OK

Migrate Specific Version

$ sqlv up 181201_000000
up 181201_000000 ... OK

Rollback Specific Version

$ sqlv down 181201_000000
down 181201_000000 ... OK

Config

Change Migration Directory

By default, the migration files are created in the ./migrations directory. If you want to change this, please set up as follows:

module.exports = {
  migrations: "otherdirectory", // default "migrations"
}

Multi-Connection

If you have multiple DB connections, you can use:

// sqlv.config.js
module.exports = {
  connections: {
    default: {
      adapter: "mysql",
      host: "localhost",
      database: "test",
      user: "root",
      password: "",
    },
    pg: {
      adapter: "pg",
      user: "root",
      password: "",     
    },
  },
}

Migrations files, you can specify a connection with a comment.

-- @sqlv connection: pg

CREATE /* ...SQL Syntax.... */;

You can specify multiple connections for one file.

-- @sqlv connection: default

CREATE /* ...SQL Syntax.... */;
CREATE /* ...SQL Syntax.... */;
CREATE /* ...SQL Syntax.... */;

-- @sqlv connection: pg

CREATE /* ...SQL Syntax.... */;
CREATE /* ...SQL Syntax.... */;

Change History Manager

There are two history manager driver, json and database.

module.exports = {
  history: {
    driver: "json",
  },
}
module.exports = {
  history: {
    driver: "json",
    path: "./yourown.history.json"
  },
}

Migration information uses the migrations table in the database. If you want to change this, you can do the following:

module.exports = {
  connections: {
    default: {
      ...
    },
    otherdatabase: {
      ...
    },
  },
  history: {
    driver: "database",
    connection: "otherdatabase",
    table: "yourownmigrationtable", // default "migrations"
  },
}

If you want to use multiple databases and set up a specific database, use:

License

MIT