2016-02-15 09:54:47 +01:00
2016-02-12 12:54:28 +01:00
2016-02-12 13:34:24 +01:00

Database migration

Detailed information about this

Setup

Configuration

All configuration needed is done in .configuration.sh.

To avoid having to enter password for selected user on each run, just use a .pgpass file.

Migration files

The files in the /migrations directory are changes to the scheme, not the full scheme.

The naming convention for migration files are:

  • 000.000.sql
  • 000.001.sql
  • 000.002.sql
  • 000.003.sql
  • 000.004.sql
  • ...and so on

Example The first file, migrations/000.000.sql may look like this:

create table users (
  name varchar(32) not null,
  primary key (name)
);

The second file, migrations/000.001.sql may look like this:

alter table users
add email varchar(256) not null;

Prerequisites

One table needs to be created for the database to make this work:

CREATE TABLE database_versions (
  version varchar(32) not null,
  is_active boolean not null default false,
  creation_date timestamp not null default current_timestamp
);

To do the actual migration, then just run:

# ./db-upgrade
S
Description
No description provided
Readme
1.6 MiB
Languages
PLpgSQL 97.7%
Shell 2.3%