A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/sastraxi/pgsh below:

sastraxi/pgsh: Branch your PostgreSQL Database like Git

pgsh: PostgreSQL tools for local development

Finding database migrations painful to work with? Switching contexts a chore? Pull requests piling up? pgsh helps by managing a connection string in your .env file and allows you to branch your database just like you branch with git.

There are only a couple requirements:

See dotenv for more details, and The Twelve-Factor App for why this is a best practice.

Language / Framework .env solution Maturity javascript dotenv high

pgsh can help even more if you use knex for migrations.

  1. yarn global add pgsh to make the pgsh command available everywhere
  2. pgsh init to create a .pgshrc config file in your project folder, beside your .env file (see src/pgshrc/default.js for futher configuration)
  3. You can now run pgsh anywhere in your project directory (try pgsh -a!)
  4. It is recommended to check your .pgshrc into version control. Why?

There are two different ways pgsh can help you manage your current connection (mode in .pgshrc):

  1. Make sure the postgres client and its associated tools (psql, pg_dump, etc.) are installed locally
  2. cp .env.example .env
  3. docker-compose up -d
  4. Run the test suite using yarn test. Note that this test suite will destroy all databases on the connected postgres server, so it will force you to send a certain environment variable to confirm this is ok.

Read up on the recommended branching model for more details.

Migration management (via knex)

pgsh provides a slightly-more-user-friendly interface to knex's migration system.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4