Code Monkey home page Code Monkey logo

Comments (6)

charettes avatar charettes commented on September 24, 2024 1

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.

charettes avatar charettes commented on September 24, 2024 1

Thanks for all your hardwork, @tbicr!

from django-pg-zero-downtime-migrations.

tbicr avatar tbicr commented on September 24, 2024

Hi, @charettes

I'll see 3 different issues in your:

  1. 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.

  1. I'll look at DatabaseSchemaEditor a bit later. Will keep you updated.

  2. 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 drop DEFAULT, 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.

tbicr avatar tbicr commented on September 24, 2024

@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.

tbicr avatar tbicr commented on September 24, 2024

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.

tbicr avatar tbicr commented on September 24, 2024

django 2.2 support added in #6

from django-pg-zero-downtime-migrations.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.