Wednesday, August 29, 2018

Re: Trying to replace a char field with a forgein key feild

Thanks for the reply.

Sadly in the process of me messing around with, I somehow fixed it. I'm not sure how, but when I get a chance I'll look through my changes and see what did it.

In the meantime, I'm going to claim user error until I can figure it out.

Thanks,
Matthew Stroud

On 8/29/18, 5:33 AM, "django-users@googlegroups.com on behalf of Michal Petrucha" <django-users@googlegroups.com on behalf of michal.petrucha@koniiiik.org> wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On Mon, Aug 27, 2018 at 09:37:03AM -0700, mattstroud via Django users wrote:
> So when we started the database, it was good enough to have a char field
> with choices. But as time progressed I need to convert that field to a
> foreign key field. The follow I'm trying to take is such:
>
>
> 1. rename <fieldname> to tmp_<fieldname>
> 2. create a new field with <fieldname>
> 3. have a RunPython fill the data for <fieldname>
> 4. delete field tmp_<fieldname>
>
> I can get steps 1 through 3 to work with out issue. But once I remove the
> old field from the code, the migration breaks because the field no longer
> exists (which makes sense). I'm curious if there is a way to work around
> this, because my googling is coming up empty.

I'm not following – why would the migration break? What part of it
would break, and how? None of what you wrote suggests that this should
in any way fail, as long as operations 1, 2, and 4 are performed with
AlterField, AddField, and RemoveField, and you use model classes
passed into RunPython through the ``apps`` argument.

Could you perhaps provide some more details about the failure that
you're experiencing?

Michal
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCgAGBQJbhoRCAAoJEHA7T/IPM/klbKAQAJrCF9WNMOOsaWc3V/5PzNN3
quKafkPijxOkSl3AlLcPE6Os/2gPAc7rQZ+jKIorkXP6/RTh1U2DgGzYhLxeEzJL
tcS8cTtfsRx50En7Rbq9MnvQd/3G/xbEPaPzIp7moB1R0z7DY6uJoY39hpeJltd4
D2OVBwtryKs3r98B2PsQuwA5m7i8qy14LzosK1TQUGeUzEwINzaGQdt07aI24hpE
XJtfkUMXk7v8t3OuEPaSNCabfK0bGhV8WYRFj1JKUONrKhTl7RCXXBpmDahH2M5P
zInUKwChxa6zOwCpZ8tgoj2NSB0xlWSBzCZPV6LXiUvy7bPIJ9N64MBbIP9ntsEL
5ozGwE8oSmVpdDAlGY8IdwnJdgJzemRokD1z2PKo4zJViDrDxdOB4dVmrJ/FjrH6
cYe022N8iHHVx9aAtMXyuitfRzcNukpUTiyXPDji3XeUAxjmR3/sezWXiCA0iDua
vc3mytzQldPw2t7E9q0a/Q4QvFAh42ALzpZzZwdVmx81j3CGbbF6GiWuYiL/xYUc
bTt9RsEAFiNiDXWXiljf94ZwDQaAd+sHCwHP+zleHHKQ4n2iAZrb+Cy4vq2uNpGi
hZRAmIgOkqcN4kaD4wnImYigydSVgJ1AtL+MTcIgm8U06uSTicjRs67+RWvmvS6G
bpaFyP2KsdzU58s0sTTA
=LaQQ
-----END PGP SIGNATURE-----

--
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+unsubscribe@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/20180829113220.GV1181%40koniiiik.org.
For more options, visit https://groups.google.com/d/optout.



________________________________

CONFIDENTIALITY NOTICE: This message is intended only for the use and review of the individual or entity to which it is addressed and may contain information that is privileged and confidential. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message solely to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify sender immediately by telephone or return email. Thank you.

--
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+unsubscribe@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/43F2B1B1-ACAA-4E51-8FD6-543B8D323EE9%40overstock.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment