[Ticket #24686] Support for Moving a Model between two Django Apps - Implementation Approach Feedback

2023-02-17 Thread Durval Carvalho


Hello Django developers,

I'm new to the community and I'm not sure if this is the right place to ask 
my question, so please let me know if there's a more appropriate channel 
for this type of discussion.

I would like to ask for feedback on my approach. I have found what I 
believe to be the best way to move a model from one app to another in 
Django. It involves four separate operations in at least 3 different 
migrations:

   1. 
   
   Rename table operation: renames the physical table name on the database. 
   This operation should be a SeparateDatabaseAndState operation and only 
   change the database, without changing any state.
   2. 
   
   Create table operation: moves the model code to the new app, and creates 
   a CreateModel only in state, with a SeparateDatabaseAndState operation.
   3. 
   
   Update all foreign keys that point to the moved model.
   4. 
   
   Delete the old model table, but only in state, using a 
   SeparateDatabaseAndState operation.
   

I've implemented this logic in a new method called "generate_moved_models" 
in MigrationAutodetector. 

 

This approach didn't break any existing tests, and now I'm focused on 
writing the text using the moving model feature with other operations.

Thank you all in advance for your feedback on this approach.

-- 
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/70112aa3-fe34-4943-8134-a571c5a875e5n%40googlegroups.com.


Re: Fellow Reports - February 2023

2023-02-17 Thread Mariusz Felisiak
Week ending February 12, 2023 

*Triaged: *
   https://code.djangoproject.com/ticket/34312 - startapp/startproject 
template should support file renames with the full context (wontfix) 
   https://code.djangoproject.com/ticket/32775 - LiveServerTestCase fails 
when query expressions are used for model ordering (fixed) 
   https://code.djangoproject.com/ticket/34313 - Thousands separator for 
Spanish language is incorrect (accepted) 
   https://code.djangoproject.com/ticket/34315 - Close button read only 
changeview of admin does not preserve filters (accepted) 
   https://code.djangoproject.com/ticket/34316 - Visual regressions in 
admin's change password form (created) 
   https://code.djangoproject.com/ticket/34318 - Add a release note that 
makemessages no longer changes .po files when up to date. (accepted) 
   https://code.djangoproject.com/ticket/34319 - 
Model.validate_constraints() crashes when constraint's validate() raises 
ValidationError without a code. (accepted) 
   https://code.djangoproject.com/ticket/34321 - Unexpected query result 
after call QuerySet.only() to ForeignKey() with 'self' reference (invalid) 
   https://code.djangoproject.com/ticket/34320 - Renaming fields with 
truncated names don't remove old constraints on Oracle. (accepted) 
   https://code.djangoproject.com/ticket/34325 - Clarify PercentRank() 
description. (accepted) 
   https://code.djangoproject.com/ticket/34326 - Standardize case for 
commands (invalid) 
   https://code.djangoproject.com/ticket/34329 - django-formset new app - i 
am facing the issue Uncaught (in promise) SyntaxError: JSON.parse (invalid) 
   https://code.djangoproject.com/ticket/34330 - QuerySet of a model having 
Meta.ordering, returns the sortable field in values_list() and values() 
(duplicate) 

*Reviewed/committed: *
   https://github.com/django/django/pull/16489 - Made PostgreSQL's 
SchemaEditor._create_index_sql() respect the "sql" argument. 
   https://github.com/django/django/pull/16527 - Fixed #34301 -- Made 
admin's submit_row check add permission for "Save as new" button. 
   https://github.com/django/django/pull/16334 - Fixed #34310 -- Added 
deletion example to one-to-one topic. 
   https://github.com/django/django/pull/16519 - Fixed #33638 -- Fixed GIS 
lookups crash with geography fields on PostGIS. 
   https://github.com/django/django/pull/16512 - Fixed #34285 -- Fixed 
index/slice lookups on filtered aggregates with ArrayField. 
   https://github.com/django/django/pull/16529 - Fixed #34317 -- Renamed 
"instance" argument of BaseModelFormSet.save_existing() method. 
   https://github.com/django/django/pull/16459 - Removed hardcoded date in 
SetCookieTests.test_far_expiration(). 
   https://github.com/django/django/pull/16531 - Fixed #34315 -- Preserved 
admin changelist filters on "Close" button. 
   https://github.com/django/django/pull/16524 - Fixed #34311 -- Updated 
serialization docs from unique_together to UniqueConstraint. 
   https://github.com/django/django/pull/16536 - Fixed #34248 -- Added 
tox.ini to MANIFEST.in. 
   https://github.com/django/django/pull/16538 - Fixed #34324 -- Mentioned 
Discord server in contributing index. 
   https://github.com/django/django/pull/16319 - Fixed #32813 -- Made 
runserver display port after binding. 
   https://github.com/django/django/pull/16539 - Fixed #34325 -- Corrected 
wording in PercentRank() docs. 
   https://github.com/django/django/pull/16537 - Refs #34140 -- Applied rst 
code-block to non-Python examples. 
   https://github.com/django/django/pull/16435 - Fixed #33213 -- Doc'd 
testing code coverage in parallel and used it. 

*Reviewed: *
   https://github.com/django/django/pull/16530 - Refs #34146 -- Fixed typos 
in tutorial. 
   https://github.com/django/django/pull/16528 - Fixed #34313 -- Updated 
thousands separator for Spanish (ES) locale. 
   https://github.com/django/django/pull/16534 - Added missing vars to 
AdminSite.each_context() docs. 

*Authored: *
   https://github.com/django/django/pull/16533 - Fixed #34319 -- Fixed 
Model.validate_constraints() crash on ValidationError with no code. 
   https://github.com/django/django/pull/16534 - Added missing vars to 
AdminSite.each_context() docs.

Best,
Mariusz

-- 
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/d7661764-7f9f-4c6b-bde8-7d396b6defddn%40googlegroups.com.