Skip to main content

SQL migrations for Postgres

Project description

SQL migrations for Postgres

PGPASSWORD=top-secret goose ./tests/master_migrations

(Assuming you have a Postgres server running on localhost:5432 with a high-entropy admin password)

Installation

pip install postgoose

Usage

usage: goose [-h] [--host HOST] [-p PORT] [-U USERNAME] [-d DBNAME]
             [-s SCHEMA] [-r ROLE] [--strict_digest_check STRICT_DIGEST_CHECK]
             [-m MIGRATIONS_TABLE_NAME] [-a AUTO_APPLY_DOWN] [-V VERBOSE] [-v]
             migrations_directory

positional arguments:
  migrations_directory  Path to directory containing migrations

optional arguments:
  -h, --help            show this help message and exit
  --host HOST
  -p PORT, --port PORT
  -U USERNAME, --username USERNAME
  -d DBNAME, --dbname DBNAME
  -s SCHEMA, --schema SCHEMA
  -r ROLE, --role ROLE

  --strict_digest_check STRICT_DIGEST_CHECK
                        Set Flase to compare with saved digest instead of re-computing digest.
                        Default is True

  -m MIGRATIONS_TABLE_NAME, --migrations_table_name MIGRATIONS_TABLE_NAME
                        Default is goose_migrations

  -a AUTO_APPLY_DOWN, --auto_apply_down AUTO_APPLY_DOWN
                        Accepts True/False, default is True

  -V VERBOSE, --verbose VERBOSE
                        Accepts True/False, default is True

  -v, --version         show program's version number and exit

Where migrations_directory is some directory of form:

./migrations
  1_up.sql
  1_down.sql
  2_up.sql
  2_down.sql
  3_up.sql
  3_down.sql

Current main difference from Play Framework migrations is that a migration in Goose is all-or-nothing.

E.g. you are on master branch on revision 5 and want to switch to a feature branch whose latest revision is 4'.

1 <- 2 <- 3 <- 4 <- 5
       \
         3' <- 4'

Applying migrations through Goose will leave you on either revision 5 (if an error is encountered) or revision 4' (if migration is successful) but not on any of 4, 3, 2, or 3'.

Testing on local machine

  • Check docs/testing.md

License

Copyright 2018 LeanTaas, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

postgoose-0.1.1.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

postgoose-0.1.1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file postgoose-0.1.1.tar.gz.

File metadata

  • Download URL: postgoose-0.1.1.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.0

File hashes

Hashes for postgoose-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a0877709e1d94ffb317a2370605e675bd6a3c53ca302504a546861e4dd698a2f
MD5 4ad15dcc0c22b78156facace34460c27
BLAKE2b-256 37a36cc5b2da0258fad91e4fac63d9349161636ce6230bd57f41f2302309333d

See more details on using hashes here.

File details

Details for the file postgoose-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: postgoose-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.0

File hashes

Hashes for postgoose-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f13b0d2f1b6935fc0b42dc46cca3861ea9b806b5843a3964690c4d86cd2255ad
MD5 a106e3d6aa77de11d598d45bb7208fa6
BLAKE2b-256 d21cecc543c01be9ebd73faedae4cfc080d184d754462bd81cf3817b576ccd77

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page