Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/purcell/postgresql-migrations

Simple Schema Migrations for PostgreSQL
https://github.com/purcell/postgresql-migrations

Last synced: about 2 months ago
JSON representation

Simple Schema Migrations for PostgreSQL

Awesome Lists containing this project

README

        

[![Build Status](https://travis-ci.org/purcell/postgresql-migrations.svg?branch=master)](https://travis-ci.org/purcell/postgresql-migrations)
Support me

## Simple Schema Migrations for PostgreSQL

### About

This repository, which began as a simple Gist, provides a tiny starter
kit and instructions for safely performing schema migrations on a
PostgreSQL database. It works by providing a PLPGSQL procedure which
can execute a chunk of SQL and then note it as having been executed,
so that it will not be executed again the next time.

We're actively using this in production over at NEC Smart Cities with
great success, so it is now somewhat proven and maintained.

### Installation

Copy `migrations.sql` to your project. Add migrations to the end of
that file in the form of calls to `apply_migration`, as shown in the
examples in that file. To apply all pending migrations, including
bootstrapping the migration function and its `migrations` table, run
the file against your database in a single transaction with psql, or
via your database connection adaptor.

```
psql -v ON_ERROR_STOP=1 -1f -- migrations.sql yourdbname
```

You should generally arrange to run migrations as the database owner
(or even the super-user), and your applications should use
less-privileged users.

### Author

This software was written by
[Steve Purcell](https://github.com/purcell).

### License and copyright

MIT license.


Author links:

[💝 Support this project and my other Open Source work](https://www.patreon.com/sanityinc)

[💼 LinkedIn profile](https://uk.linkedin.com/in/stevepurcell)

[✍ sanityinc.com](http://www.sanityinc.com/)

[🐦 @sanityinc](https://twitter.com/sanityinc)