@tomkcey/pg-migrate
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

GitHub Actions Workflow Status

How to use

Creating a migration file

For creating migration files you can use the CLI.

npx @tomkcey/pg-migrate create <migration_filename>

While database access is not required at this step, kkowing where to store those migrations is. In any case, here's all the environment variables you will need to use this program through the CLI.

PGUSER=<username>
PGPASSWORD=<password>
PGHOST=localhost
PGPORT=5432
PGDATABASE=<database>
PGSSL=<true/false>
MIGRATION_PATH=<absolute-path-to-migrations-dir>
MIGRATION_TABLE=<tablename>

Only MIGRATION_PATH is required if only using migration file creation through the CLI.

Running migrations up

import { Migrator, MigratorOptions } from "@tomkcey/pg-migrate";

const options: MigratorOptions = { ... }

const migrator = new Migrator(options, someLogger);

await migrator.up();

or npx @tomkcey/pg-migrate up

Running migrations down

import { Migrator, MigratorOptions } from "@tomkcey/pg-migrate";

const options: MigratorOptions = { ... }

const migrator = new Migrator(options, someLogger);

await migrator.down();

or npx @tomkcey/pg-migrate down


Roadmap

  • Create custom errors
  • Add tests to up and down in Migrator

Package Sidebar

Install

npm i @tomkcey/pg-migrate

Weekly Downloads

1

Version

0.2.0

License

UNLICENSED

Unpacked Size

52.1 kB

Total Files

31

Last publish

Collaborators

  • tomkcey