Hello,

I recently ran into a problem with a custom migration containing code 
manipulating the data.


The simplified scenario is:

  *   a given model has been defined with its set of fields. So far so good.
  *   later on, a new field has been added, intended to contain a required 
read-only value which is automatically generated when creating new instances
  *   to fulfill the required constraint for existing instances, a custom 
migration has been added (let's call it M1 for reference) to generate the 
missing values. No problem, all (migrations, application,...) is working fine.

Later on, a new field has been added to the model (let's call it F). The 
associated automatic migration (let's call it M2) and the application still run 
fine.


A problem now occurs when running unit tests. At the time the temporary test 
database creation process runs, in hangs on migration M1. The reason is that 
when it runs, it loads the current model class definition which includes the 
field F. But this field does not exist yet in the database (since created later 
by the migration M2). Shortly said, the problem comes from the model and the 
database not being in sync when running M1.


Since I imagine that this situation is not uncommon, there should be an 
appropriate method to be applied in this case. Could anybody give some hints 
about the right way to proceed please ? Thanks in advance.


Best regards


Eric

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/DB7P193MB033118E2C1336E608FE94EC58CA30%40DB7P193MB0331.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.

Reply via email to