On Wed, Apr 22, 2020 at 4:06 PM Adam Johnson <m...@adamj.eu> wrote:

> Hi djangonauts,
>
> In a blog post earlier this year I outlined my technique to prevent Django
> creating migration files with automatic date names. I had a lot of response
> with other techniques and ended up adding two more techniques to the post.
> It's at
> https://adamj.eu/tech/2020/02/24/how-to-disallow-auto-named-django-migrations/
> .
>
> The problem with such migration names:
>
> When you run Django’s manage.py makemigrations, it will try to generate a
>> name for the migration based upon its contents. For example, if you are
>> adding a single field, it will call the migration 0002_mymodel_myfield.py.
>> However when your migration contains more than one step, it instead uses a
>> simple ‘auto’ name with the current date + time, e.g.
>> 0002_auto_20200113_1837.py. You can provide the -n/--name argument to
>> makemigrations, but developers often forget this.
>>
>
Actually I would prefer all the automatically-generated migration file
names to be ‘auto’ name with the current date + time, e.g.
0002_auto_20200113_1837.py (except the initial migration which could remain
"0001_initial.py"). I don't think there is a need to name the migrations
and actually migration names such as "0004_user_has_confirmed_email.py"
(which is one of our migrations in Speedy Net) makes it look like someone
named it specifically, although it's also automatically generated by
Django. Also I prefer the file name to contain the date the migration was
generated. Most of our migrations, at least 98% I think, were generated
automatically by running "make_migrations" and I would like to keep it this
way. Only rarely I would find a need to manually write a migration. If the
file name is not like ‘auto’ name with the current date + time, it looks
like a migration which was written by a developer.

אורי

-- 
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-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CABD5YeEHR6XxPDY_YbdFXW_C9M5JSy3DAwD3FNg%2Bzd-pV%3DSXLw%40mail.gmail.com.

Reply via email to