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

gratin

v0.1.2

Published

Use gratin start migratin'

Downloads

1

Readme

What

Gratin is a very simple database migration tool that will:

  • Read all the files from a given folder, assuming each of them is a valid script for your target database.
  • Connect to a given database
  • Apply each file in a transaction
  • Keep track of each applied migration in the database itself, creating the table gratin_changelog.

Installation

npm i --save gratin

Usage

Create a new file, like migrator.ts, which will be the entry point for the migrations tool:

import { join } from 'path';

import { Gratin, Postgres } from 'gratin';

const gratin = new Gratin({
	migrationsFolder: join(__dirname, 'migrations'),
	database: new Postgres({
		host: '127.0.0.1',
		port: 5432,
		database: 'postgres',
		username: 'postgres',
		password: '12345',
	}),
});

gratin.run();

This will find every file inside ./migrations folder (relative to the script itself) and apply each of them to the database in separate transactions, creating a changelog in the database to keep track of all the applied migrations.

And, because it's just code, you can do whatever you want to get the proper database credentials, do some tasks before or after migrating, etc.

Now all you have to do is run it with something like ts-node or compile it with Typescript tsc.

Database support

Currently, only PostgreSQL. But you could create a new implementation of IDatabase on your own and use it. The PostgreSQL implementation is included in the package as a commodity.

Credits