Hi there,

Wondering if there's any tool out there to make a zero downtime field type 
change easier. I want to change a django model field from one type to 
another, and the format of the field in the database is slightly different.

I've come up with a process I think will work, but it will be rather 
tedious if done manually. Wondering if there's a more automated approach or 
other tools out there already. I'd like to come up with a general solution 
for use in the future, but right now trying to tackle converting UUIDField 
from django-extensions to the built in django version.
https://github.com/django-extensions/django-extensions/issues/647

I was thinking about maybe using a custom field that supports both types, 
but not exactly sure how to write a custom field that would do that.

If it helps, the manual process I'm thinking about kind of goes as follows:

# existing model:
class Model:
field = OldField()

# add field_old with OldField type
# when updating or adding rows start writing to both fields
# copy data from field to field_old
class Model:
field = OldField()
field_old = OldField()

# stop using field, only use field_old
# remove field
class Model:
field_old = OldField()

# create field with new type
# when updating or adding rows start writing to both fields in their 
respective formats
# copy data from field_old in old format to field in new format
class Model:
field = NewField()
field_old = OldField()

# stop using field_old
# remove field_old
class Model:
field = NewField()

Thanks for your help!

--
Kyle Mulka
http://www.kylemulka.com

-- 
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/b16ffdee-74d6-4ba2-ac1f-b5bd9cf1e40b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to