Skip to main content

No project description provided

Project description

Build Status Coverage status

Django application providing database migration tooling to automate their deployment.

Inspired by a 2015 post from Ludwig Hähne and experience dealing with migration at Zapier.

Installation

pip install django-syzygy

Usage

Add ‘syzygy’ to your INSTALLED_APPS

# settings.py
INSTALLED_APPS = [
    ...
    'syzygy',
    ...
]

Setup you deployment pipeline to run migrate –pre-deploy before rolling out your code changes and migrate afterwards to apply the postponed migrations.

Concept

Syzygy introduces a notion of prerequisite and postponed migrations with regards to deployment.

A migration is assumed to be a prerequisite to deployment unless it contains a destructive operation or the migration has its stage class attribute set to POST_DEPLOY. When this attribute is defined it will bypass operations based heuristics.

e.g. this migration would be considered a prerequisite

class Migration(migrations.Migration):
    operations = [
        AddField('model', 'field', models.IntegerField(null=True))
    ]

while the following migrations would be postponed

class Migration(migrations.Migration):
    operations = [
        RemoveField('model', 'field'),
    ]
from syzygy import Stage

class Migration(migrations.Migration):
    stage = Stage.POST_DEPLOY

    operations = [
        RunSQL(...),
    ]

In order to prevent the creation of migrations mixing operations of different stages this package registers system checks. These checks will generate an error for every migration with an ambiguous stage.

e.g. this migration would result in a check error

class Migration(migrations.Migration):
    operations = [
        AddField('model', 'other_field', models.IntegerField(null=True)),
        RemoveField('model', 'field'),
    ]

Migration revert are also supported and result in inverting the nature of migrations. A migration that is normally considered a prerequisite would then be postponed when reverted.

With this new notion of migration stage it’s possible for the migrate command to target only migrations meant to be run before a deployment using the –pre-deploy flag or error out in the case on an ambiguous plan.

Development

Make your changes, and then run tests via tox:

tox

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

django-syzygy-0.1.0a1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

django_syzygy-0.1.0a1-py2.py3-none-any.whl (12.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-syzygy-0.1.0a1.tar.gz.

File metadata

  • Download URL: django-syzygy-0.1.0a1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

File hashes

Hashes for django-syzygy-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 4fbe1c3946d479ba35aa796b421bdc072bd360772836e763c4f8550d4f3ea42e
MD5 bff97f2968b70c170cfd9a5d5cf0cba9
BLAKE2b-256 f7dbb8d5a7d771725f0efebf07a54ae81fcb50510a76c0a9c7a03448bf76ec62

See more details on using hashes here.

File details

Details for the file django_syzygy-0.1.0a1-py2.py3-none-any.whl.

File metadata

  • Download URL: django_syzygy-0.1.0a1-py2.py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

File hashes

Hashes for django_syzygy-0.1.0a1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3289b3248a9a606527a97cf7abdcb39811002afdff63e791a6e676199db5bf52
MD5 64824fa9aed29b751f98f729c1095967
BLAKE2b-256 6496a869b84a213d38f3e62132c834a259cde370aceb3a1206e02bcf85c6ebbd

See more details on using hashes here.

Supported by

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