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

migraphile

v1.1.0-beta.7

Published

A migration tool that combines Migra and Graphile Migrate

Downloads

563

Readme

migraphile

A migration tool that combines Migra and Graphile Migrate

Installation

yarn add migraphile

How It Works

Migraphile is a wrapper around Migra and allows users to enable drift detection with Graphile Migrate. With both of the features below, a developer can enable a smooth experience in generating and applying migrations to their database based on changes to a schema (orm) database.

Drift Detection

To do this, you will need to add the following to your .gmrc file that graphile-migrate produces.

{
  // Previously managed via BASELINE_FILE
  "afterReset": "schema/supabase.sql",
  
  // Simulate what v1.0.* would have done
  "beforeCurrent": [
    {
      "_": "command",
      "command": "yarn migraphile fix_drift"
    }
  ],
  "afterAllMigrations": [
    {
      "_": "command",
      "command": "yarn migraphile fix_drift"
    }
  ]
}

The fix_drift command is smart enough to run the necessary migrations to fix the drift. This is done by comparing the shadow database to the local database. The fixes are then applied to the local database. This command is intended to be called within the graphile-migrate process.

Migraphile will also pull some additional parameters from your environment. Create an .env file with the following parameters:

# graphile migrate
DATABASE_URL=postgres://user:pass@localhost:54322/postgres
ROOT_DATABASE_URL=postgres://user:pass@localhost:54322/template1
SHADOW_DATABASE_URL=postgres://user:pass@localhost:54322/shadow

# migraphile
APP_DATABASE_URL=postgres://user:pass@localhost:54322/postgres
ORM_DATABASE_URL=postgres://user:pass@localhost:54322/knex
ORM_NAME=Knex
OUTPUT_FILE_PATH=current/1-current.sql
SCHEMAS=public

One note is that the DATABASE_URL is the same as the APP_DATABASE_URL because graphile-migrate likes to override the variable Migraphile needs to be able to grab the original value.

Generate Migrations

You will need to run yarn migraphile to enable migration generation. This will listen for commands and generate a migration file to the given OUTPUT_FILE_PATH. For graphile-migrate this is usually migrations/current/1-current.sql.

Requirements

  • Docker: Migraphile uses Docker to run Migra in a container as it is a python application.