Hi everyone 👋🏻

After a long period of inactivity I'm back at it with the help of Taylor.

As a reminder: 
Here is the ticket: https://code.djangoproject.com/ticket/29843 
Here is the initial PR: https://github.com/django/django/pull/10540

After some experiments and discussions it felt like while the 
implementation might solve the initial problem, it's a bit under the hood 
and will be hard to debug if something goes wrong.
The idea was to inject operations at the time of running `migrate`.

So... we went back to the idea of having hooks during the `makemigrations` 
process instead, so that the operations would be written to the migration 
files, which would make it more explicit and less risky. Here is a first 
draft of how it would look like: https://github.com/django/django/pull/14229
.

1. We know that the `makemigrations` process is complicated, so before we 
invest more time down that path, is there something obvious we might be 
missing?
2. What do you think of this approach with hooks (pre and post 
"add_operation")?
3. Do you think it would be a useful feature for other third party apps as 
well (not just content types and permissions)?

Thank you for your input, stay safe

Arthur & Taylor

On Saturday, October 13, 2018 at 12:56:25 PM UTC-6 petter.s...@gmail.com 
wrote:

> I encountered a similar issue recently, but with auth permissions.
>
> It is described here: https://code.djangoproject.com/ticket/29843
>
> On Wednesday, October 3, 2018 at 1:01:37 PM UTC+2, Marcin Nowak wrote:
>>
>> Hello.
>>
>> There is a huge issue with content types framework. The data is loaded 
>> after every migration (post_migrate signal) automatically, and this 
>> approach is against db data consistency.
>> The biggest problem is with data migrations, which are applied at the 
>> first time (on clean database). Any data migration which depends on some 
>> content types will not insert the data.
>>
>> The sequence looks like this:
>>
>>    1. create db
>>    2. insert into auth_permission ...  inner join django_content_type ...
>>    3. post migrate: insert into django_content_type ...
>>
>>
>> Two things are wrong:
>>
>>    - automatic creation of content types
>>    - creation of content types after running migrations
>>
>> Solution:
>>
>>    - creation of new app should add very first migration, which will add 
>>    entry to the content types
>>    - create_contentypes handler should be removed from post_migrate 
>>    signal
>>
>> Any data migration, which depends on some content types, should be 
>> declared with proper dependency. This will guarantee existence of the 
>> required content type entry.
>>
>>
>> BR,
>> Marcin
>>
>>
>>

-- 
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/9f6f9bf3-ad26-4874-939e-a7ad3e201a98n%40googlegroups.com.

Reply via email to