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

migurt

v3.0.9

Published

Database migration tool

Downloads

56

Readme

migurt 🍦

A database migration tool

Build Status JavaScript Style Guide: Prettier Dependencies

Migurt lets you write database migrations and seeds in your database's language.

(Currently, only works with PostgreSQL)

Installation

npm i -g migurt

Usage

migurt help [COMMAND]

Displays help.

[COMMAND] - Optional. The name of a command.


migurt create-migration --name <NAME>

Create new migration and matching reversion files.

<NAME> - Required. The name of the migration file. Prefixed to the name will be a timestamp. Suffixed to the name will be ".sql".

Example

migurt create-migration --name create_table_companies

will create files ./db/migrations/up/1525396716884_create_table_companies.sql and ./db/migrations/down/1525396716884_create_table_companies.sql (creating the directories if they don't exist).

Now, write your migrations in PostgreSQL. For example

-- ./db/migrations/up/1525396716884_create_table_companies.sql

CREATE TABLE public.companies (
  id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
  name TEXT NOT NULL UNIQUE,
  active BOOLEAN NOT NULL DEFAULT TRUE
);

CREATE UNIQUE INDEX companies_id_idx ON public.companies (id);
CREATE UNIQUE INDEX companies_name_idx ON public.companies (name);
CREATE INDEX companies_active_idx ON public.companies (active);
-- ./db/migrations/down/1525396716884_create_table_companies.sql

DROP TABLE public.companies;

migurt create-seed --name <NAME>

Create new seed and matching reversion files.

<NAME> - Required. The name of the seed file. Prefixed to the name will be a timestamp. Suffixed to the name will be ".sql".

Example

migurt create-seed --name create_companies

will create files ./db/seeds/up/1526829902471_create_companies.sql and ./db/seeds/down/1526829902471_create_companies.sql (creating the directories if they don't exist).

Now, write your seeds in PostgreSQL. For example

-- ./db/seeds/up/1526829902471_create_companies.sql

INSERT INTO public.companies (name) VALUES ('E Corp');
-- ./db/seeds/down/1526829902471_create_companies.sql

DELETE FROM public.companies WHERE name = 'E Corp';

migurt migrate --number <NUMBER>

Run migrations.

<NUMBER> - Required. The number of migrations to run. Enter a number to run that many migrations from the last ran migration.


migurt seed --number <NUMBER>

Run seeds.

<NUMBER> - Required. The number of seeds to run. Enter a number to run that many seeds from the last ran seed.


migurt revert-migrations --number <NUMBER>

Revert migrations.

<NUMBER> - Required. The number of migrations to revert. Enter a number to revert that many migrations from the latest.


migurt revert-seeds --number <NUMBER>

Revert seeds.

<NUMBER> - Required. The number of seeds to revert. Enter a number to revert that many seeds from the latest.


Configuration

migurt parses environment variables from a .env file when process.env.NODE_ENV != 'production'.

Below are the environment variables and their defaults.

NOTE: DATABASE_URL is required.

DATABASE_URL=
DIRECTORY_DOWN_MIGRATIONS="./db/migrations/down"
DIRECTORY_DOWN_SEEDS="./db/seeds/down"
DIRECTORY_UP_MIGRATIONS="./db/migrations/up"
DIRECTORY_UP_SEEDS="./db/seeds/up"
TABLE_NAME_MIGRATIONS="public.migrations"
TABLE_NAME_SEEDS="public.seeds"

TODO

  • [ ] Add MySQL support.