peopledoc/django-MacFly

Name: django-MacFly

Owner: PeopleDoc

Description: Output sql migrations for ahead of time schema changes.

Created: 2015-10-06 13:03:46.0

Updated: 2017-11-28 21:42:38.0

Pushed: 2015-12-22 13:18:05.0

Homepage: null

Size: 21

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

django-MacFly ? Forward To The Past

Output sql migrations for ahead of time schema changes.

TL;DR
install django-MacFly
ython
ALLED_APPS += ['django_macfly']

On a develop environment, deploy the old (version N) code and run migrations. Then, deploy the new code (version N+1) without running the migrations.

Then run:

on manage.py sqlmigratefwd

Read the result, think, hack, do.

Rationale

Here, at Peopledoc we found that:

Our strategy for schema migration is to run migrations ahead of time, the database is migrated to schema N+1 while the code is at N.

This strategy requires coding discipline (do not rename a DB Column, do not change a column type…) and we needed a tool that checks the code changes, warn us if the changes are not ZDD-friendly, and gather all (safe) SQL commands to make the migration.

WARNING

This is NOT AT ALL an automatic migration tool. It's just a (dumb) HELPER. It outputs hints that you MUST read and understand. Your ahead-of-time migration will probably need DB triggers, query re-writing, default values and all sort of DBA voodoo stuff to work properly. MacFly DO NOT handle this. Candide use may eat your data and voids even the no-warranty-of-any-kind clause.

What it does

Basically it walks through pending migration (using django migrate internals).

For each migration:


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.