Comments (6)
Ahh you're right about the weird way Django deals with database level defaults. This is already tracked in https://code.djangoproject.com/ticket/470 which you might want to CC.
from django-pg-zero-downtime-migrations.
Thanks for all your hardwork, @tbicr!
from django-pg-zero-downtime-migrations.
Hi, @charettes
I'll see 3 different issues in your:
- A bit unclear what warnings/errors you propose to integrate to Django's core, because standard postgres backend extend base backend, but for different databases this warnings can be different.
So I can help you to highlight potential unsafe operations for postgres. But I cannot to decide to add it to django core.
-
I'll look at
DatabaseSchemaEditor
a bit later. Will keep you updated. -
About postgres 11 it's save to add
DEFAULT
value but standard django's behavior use it only to set all values in new column and than dropDEFAULT
, see example:
dependencies = [
('yyy', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='test',
name='test2',
field=models.CharField(default='test', max_length=10),
),
]
Will execute next SQL:
LOG: statement: ALTER TABLE "yyy_test" ADD COLUMN "test2" varchar(10) DEFAULT 'test' NOT NULL
LOG: statement: ALTER TABLE "yyy_test" ALTER COLUMN "test2" DROP DEFAULT
LOG: statement: COMMIT
If you try to insert any new row to this table from old code (that doesn't know about new changes yet), then you will get exception that test2
column required. So unfortunately postgres 11 doesn't bring much for current django logic.
from django-pg-zero-downtime-migrations.
@charettes , thanks that highlight me point with DatabaseSchemaEditor changes, I'll commented it, there are a few points that should be changed for django 2.2 support, so I will wait for django 2.2 release to fix all issues.
from django-pg-zero-downtime-migrations.
Hi, @charettes , I created django/django#10789 (https://code.djangoproject.com/ticket/30060#ticket) and #6 for django 2.2 support.
from django-pg-zero-downtime-migrations.
django 2.2 support added in #6
from django-pg-zero-downtime-migrations.
Related Issues (11)
- Postgis support HOT 3
- migrations.DeleteModel locks DB when it has ForeignKey field HOT 5
- Unchanged `db_table` in `RenameModel` raises `Unsafe.ALTER_TABLE_RENAME`
- Publish release to pypi? HOT 2
- Do you have a workflow for running `prettier` on markdown files? HOT 7
- Django 4.1: `'DatabaseSchemaEditor'` has no attribute `'sql_create_sequence'` HOT 2
- Flag for deeming CREATE INDEX operation unsafe HOT 8
- DatabaseSchemaEditorMixin._alter_column_type_sql() takes 5 positional arguments but 7 were given HOT 1
- Drop support for Python 3.6 HOT 4
- Using django-pg-zero-downtime-migrations our table is locked HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-pg-zero-downtime-migrations.