Critical hints about Django migrations

130 views
Skip to first unread message

Paolo Melchiorre

unread,
Aug 6, 2020, 3:27:40 PM8/6/20
to django-d...@googlegroups.com
HI all,

I would suggest reading this interesting article by Daniele Varrazzo
(the maintainer of psycopg2 and creator of psycopg3) on Django
migrations.

It contains some criticisms but I also think some interesting hints
for improving Django ORM :
https://www.varrazzo.com/blog/2020/07/25/surviving-django/

See you,
Paolo

--
Paolo Melchiorre

https://www.paulox.net

Andrew Godwin

unread,
Aug 6, 2020, 3:46:23 PM8/6/20
to '1337 Shadow Hacker' via Django developers (Contributions to Django itself)
While I agree with some of the author's points, I think a critical piece of context is that Django migrations are designed for the 90% case - i.e., people who just want something to work on a small scale and don't need to worry about many aspects of the database yet.

Like all parts of Django, it's designed to be progressively ignorable if you need to, and even deliberately includes a way to run SQL migrations (as the author suggests) complete with state tracking and no need to write a separate script, and is the intended approach for larger teams/codebases like the ones I work on. Migrations isn't meant to only be "makemigrations" and the model-based approach; there's also an underlying SQL application and dependency ordering engine that can be used standalone.

Andrew
-- 
You received this message because you are subscribed to the Google Groups "Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.


Jure Erznožnik

unread,
Aug 10, 2020, 1:58:45 AM8/10/20
to django-d...@googlegroups.com
It seems to me that article is written by a guy who has a lot of
knowledge of the database engine and has some issues (mostly) with
Django migrations system. His solution to the problem is to use direct
SQL statements which of course can be more finely controlled than
whatever Django creates.

While Django migrations really is a pain sometimes, it does 95% of work
automatically and keeps you from worrying about schema changes that you
made in your models. While I've been programming migrations by hand all
my life before Django - and I DO see the advantages - I'm not sure I
need those advantages. I could use some simplification and a bit less
nitpicking, but I haven't yet encountered a need to hand code the
migrations.

The rest of features Django doesn't have, I can use (and sometimes do)
just the way he proposes: by simply defining them and having the DB
server do it without Django's knowledge. So, no problem there...

So far Django has kept most of the DB issues I've been suffering from in
the past away from me. And I'm quite happy to have them there. Away.

LP,
Jure
Reply all
Reply to author
Forward
0 new messages