https://github.com/50-course/blue-green-database-deployment-django
Complex Schema Migrations exploration in django - The Canary approach
https://github.com/50-course/blue-green-database-deployment-django
django migrations python
Last synced: 17 days ago
JSON representation
Complex Schema Migrations exploration in django - The Canary approach
- Host: GitHub
- URL: https://github.com/50-course/blue-green-database-deployment-django
- Owner: 50-Course
- Created: 2024-02-29T00:55:15.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-29T01:12:37.000Z (over 2 years ago)
- Last Synced: 2025-03-22T09:43:44.412Z (about 1 year ago)
- Topics: django, migrations, python
- Language: Python
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Blue Green Deployment is a simple project to explore managing database state in production such as the `Blue-Green-Deployment` techique.
## Blue-Green-Deployment
Django provides a special migration function, `migrations.SeperateDatabaseAndState`, to separate the database schema and the data. This is useful for managing database state in production such as the `Blue-Green-Deployment` techique.
Underneath, it alters the database schema and the data separately. It is useful for managing database state in production such as the `Blue-Green-Deployment` techique.
### Usage
```python
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('myapp', '0001_initial'),
]
operations = [
migrations.SeparateDatabaseAndState(
database_operations=[
migrations.RunSQL(
"CREATE TABLE myapp_mymodel (id int, name varchar(30))",
"DROP TABLE myapp_mymodel"
),
],
state_operations=[
migrations.CreateModel(
name='MyModel',
fields=[
('id', models.AutoField(primary_key=True)),
('name', models.CharField(max_length=30)),
],
),
],
),
]
```