0.1.5 • Published 10 months ago
pg-change v0.1.5
pg-change
Postgres migration tool built with Node.js using the Postgres.js client
Install
npx pgChange or npm i -g pgChange
Usage
Create a pgChange.json configuration file
Put this pgChange.json configuration file in the root directory of your project with your own values here:
{
"migrationsPath": "migrations",
"postgresHost": "localhost",
"postgresPort": "5432",
"postgresUser": "postgres",
"postgresPassword": "password",
"postgresDb": "postgres"
}Don't forget to add pgChange.json to your .gitignore file
Create a migration
pgChange create users
Created migration 1724709481967_users.jsEdit the created migration
migrations/1724709481967_users.js:
export default async function (sql) {
return sql`
CREATE TABLE USERS (
id SERIAL PRIMARY KEY,
email TEXT NOT NULL,
password TEXT NOT NULL
);
`
}Run all the latest migrations that have not run
pgChange run-latest
Running migration 1724709481967_users.jsRun a specific migration
pgChange run 1724709481967_users.js
Running migration 1724709481967_users.jsDevelopment
npm i
npm link