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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@quave/migrations-redshift

v1.0.0

Published

AWS Redshift Data API adapter for @quave/migrations

Readme

@quave/migrations-redshift

AWS Redshift adapter for @quave/migrations, built on the Redshift Data API. No persistent connection pool — each statement is executed via ExecuteStatement and polled with DescribeStatement.

Works with both Serverless workgroups and provisioned clusters, authenticating via DbUser or a Secrets Manager SecretArn.

Install

npm install @quave/migrations-redshift @aws-sdk/client-redshift-data

Usage

Serverless

import { createRedshiftMigrations } from '@quave/migrations-redshift';

const migrations = createRedshiftMigrations({
  database: 'dev',
  workgroupName: 'my-wg',
  region: 'us-east-1',
});

Provisioned

const migrations = createRedshiftMigrations({
  database: 'dev',
  clusterIdentifier: 'my-cluster',
  dbUser: 'admin',            // OR secretArn: 'arn:aws:secretsmanager:...'
  region: 'us-east-1',
});

Writing migrations

migrations.add({
  version: 1,
  name: 'create events table',
  up: async (_m, { execute }) => {
    await execute(`
      CREATE TABLE events (
        id        BIGINT IDENTITY,
        payload   SUPER,
        created_at TIMESTAMP DEFAULT SYSDATE
      );
    `);
  },
});

await migrations.migrateTo('latest');

The ctx.execute(sql, params?) helper submits a statement, polls to completion, and returns { rows, columnMetadata, numberOfRecordsUpdated }. Parameters use the Data API format: [{ name: 'foo', value: '42' }] and are referenced in SQL as :foo.

Options

createRedshiftMigrations(opts) accepts all MigrationOptions plus:

| Option | Purpose | |---|---| | database (required) | Redshift database name. | | workgroupName xor clusterIdentifier | Pick Serverless vs. provisioned. | | dbUser | Required for provisioned unless using secretArn. | | secretArn | Secrets Manager ARN for IAM-less auth. | | region | AWS region (falls back to SDK defaults). | | schemaName / tableName | Control-table identifier. Defaults "public"."migrations_control". | | pollIntervalMs / pollMaxIntervalMs | DescribeStatement polling cadence. Defaults 100 ms → 2000 ms. | | statementTimeoutMs | Max wait per statement. Default 300 000 ms. | | maxThrottleRetries | Retry budget for ThrottlingException / TooManyRequestsException. Default 5. | | client | Inject a pre-built RedshiftDataClient (useful for custom credentials or mocking). |

Distributed lock

Each tryLock() call:

  1. Generates a fresh UUID nonce.
  2. UPDATE ... SET locked = TRUE, lock_nonce = :nonce WHERE id = 'control' AND locked = FALSE;
  3. SELECT lock_nonce FROM ... — we own the lock iff the returned nonce matches ours.

Under concurrent attempts, Redshift's serializable isolation guarantees exactly one winner: the other caller either sees locked = TRUE (updates zero rows) or aborts with a serialization error (SQLSTATE 40001, matched by message), both of which return false from tryLock().

The read-back is chosen over NumberOfRecordsUpdated because that count is unreliable under Data API transient-error retry. The nonce is idempotent under retry.

Control table

CREATE TABLE IF NOT EXISTS "public"."migrations_control" (
  id          VARCHAR(16) NOT NULL,
  version     INTEGER     NOT NULL DEFAULT 0,
  locked      BOOLEAN     NOT NULL DEFAULT FALSE,
  lock_nonce  VARCHAR(64),
  locked_at   TIMESTAMP,
  PRIMARY KEY (id)
);

Created automatically on first operation.

Testing

  • Unit tests use aws-sdk-client-mock + an in-memory SQL simulator — no AWS credentials needed.

  • Integration tests in src/__tests__/redshiftBackend.integration.test.ts are skipped unless environment variables are set:

    REDSHIFT_DATABASE=dev \
    REDSHIFT_WORKGROUP=my-wg \
    AWS_REGION=us-east-1 \
    npm test -w @quave/migrations-redshift

License

MIT