Skip to main content

Copyright (c) 2011-2018, Canonical Ltd

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 only.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. GNU General Public License version 3 (see the file LICENSE).

lazr.postgresql contains various helpers used by Launchpad for PostgreSQL support. Primary amongst these is the Slony aware database migrations facility.

Dependencies

  • Python 2.7+

Testing Dependencies

Usage

Database migrations

The upgrade tool will apply data migrations to PostgreSQL or Slony environments.

Each migration is a SQL file named patch-$major-$minor-$point-$type.sql. Major, minor and point are integers that provide a sequence for how patches are applied. The type tells the migration applier whether the migration should be applied in a normal transaction, directly to all the nodes in the cluster in a transaction, or directly to all the nodes in a cluster outside of a transaction. These are indicated by ‘std’, ‘direct’ and ‘concurrent’.

If a patch application is interrupted in anything other than ‘standard’ mode, manual cleanup may be required (e.g. because a half built index will be in place on some nodes).

For instance a file called patch-1-2-3-concurrent.sql will be applied in the following way on a non-Slony environment:

  • A transaction on the master will be opened and the row 1-2-3 added to the list of applied patches. This prevents other migrations being attempted simultaneously.

  • Then the contents of the patch file will be executed.

  • The end timestamp for the 1-2-3 row will be updated.

  • Finally the transaction is committed.

In a Slony environment the following would happen:

  • A transaction on the master will be opened and the row 1-2-3 added to the list of applied patches. This prevents other migrations being attempted simultaneously.

  • On all nodes the the contents of the patch file will be executed in separate connections outside of a transaction.

  • The end timestamp for the 1-2-3 row will be updated.

  • Finally the transaction is committed.

A single invocation of upgrade.py will only apply std, or direct + concurrent patches unless the –all parameter is given, when it will loop until all patches are applied.

More coming soon.

Installation

Either run setup.py in an environment with all the dependencies available, or add the working directory to your PYTHONPATH.

Development

Upstream development takes place at https://launchpad.net/lazr-postgresql. To setup a working area for development, if the dependencies are not immediately available, you can use ./bootstrap.py to create bin/buildout, then bin/py to get a python interpreter with the dependencies available.

To run the tests use the runner of your choice, the test suite is lazr.postgresql.tests.test_suite.

For instance:

$ PYTHONPATH=src bin/py -m testtools.run lazr.postgresql.tests.test_suite

If you have testrepository you can run the tests with it:

$ testr run

Download files

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

Source Distribution

lazr_postgresql-4.0.0.tar.gz (32.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lazr_postgresql-4.0.0-py3-none-any.whl (32.7 kB view details)

Uploaded Python 3

File details

Details for the file lazr_postgresql-4.0.0.tar.gz.

File metadata

  • Download URL: lazr_postgresql-4.0.0.tar.gz
  • Upload date:
  • Size: 32.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for lazr_postgresql-4.0.0.tar.gz
Algorithm Hash digest
SHA256 95cc7a416c9dab6e21df5e32dbc13f06dc2020829cbc1a47f184eb02a1673f97
MD5 b63cc652d99f2d75c2fd4dbd17389573
BLAKE2b-256 9db9092a24168b4b77280da41004a2d142f572e6f2bdc72775354654ac004125

See more details on using hashes here.

File details

Details for the file lazr_postgresql-4.0.0-py3-none-any.whl.

File metadata

  • Download URL: lazr_postgresql-4.0.0-py3-none-any.whl
  • Upload date:
  • Size: 32.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for lazr_postgresql-4.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 64d24cbd714d8eb16edbe9f856572e60a69879b8478b98101fc274dcb18c6dbc
MD5 ac08f58d0a03ea7e59fa4dfc7240538d
BLAKE2b-256 eb43026603b6123c8b25a0e3ecb0390aaa300c518e57d3a1879c6b170b34e3fb

See more details on using hashes here.

Supported by

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