Metadata-Version: 2.4
Name: django-green-migration
Version: 1.1.4
Summary: Generate a green migration files for Django
Author-email: Bang Dao <bang@eoh.io>
License: MIT License
        
        Copyright (c) 2025 Bang Dao
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/eoh-jsc/django-green-migration
Keywords: django,green,migration
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: django>=4.0.0
Provides-Extra: dev
Requires-Dist: pip-tools; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: bumpver; extra == "dev"
Dynamic: license-file

# django-green-migrations
Version 1.1.4

While the server is running,
if you deploy a new version which contains a migration that drop a field, it will make your production down. 
This is because the migration will be executed before the new code is deployed.
This package will help you to avoid this problem.

## Normal deployment
1. Deploy new code to server
2. Keep server running
3. Run migrations
4. Switch to new code
5. Destroy old code

At step 3, if the migration contains a field drop, the server will be down.

## Green deployment
1. Deploy new code to server
2. Keep server running
3. Run green migration ```python manage.py green_migrate > output.json```
4. Run migrations
5. Switch to new code
6. Destroy old code
7. Run pos green migration ```python manage.py pos_green_migrate output.json```

At step 3, it will modify `drop` migration to `nullable and blankable` migration, this will help both old and new code to work.

At step 7, it will read the output from step 3 to drop fields, this will help to clean up the database.

## Installation
1. Install package
```pip install django-green-migration```
2. Add `green_migration` to `INSTALLED_APPS`
3. Setup deployment like above explanation (make sure don't commit changes at step 3 to git)
