Hi,

Yes you can roll back your migrations (I think).... But you weren't able to
get by that migration and it's only that migration that you need to handle.
The other migrations haven't yet been migrated and you can just delete them
from your disk in that case?

Regards,

Andréas


Den mån 12 nov. 2018 kl 19:58 skrev china <challakart...@gmail.com>:

> Hi Andreas,
>
> Thank you for you quick response
>
> Is it possible if remove my migration files and rollback my migration to
> three  migrations back..?
>
> Thanks,
> Karthik
>
> On Monday, November 12, 2018 at 12:26:23 PM UTC-5, Andréas Kühne wrote:
>>
>> Hi,
>>
>> You are changing a CharField into a ForeignKey field with data present.
>> So when the migration tries to run, the reports_to field contains
>> information with a string in it - the database server then tries to set it
>> to a ForeignKey field, which is an integer field per default. This data
>> migration doesn't work and that is what the error is saying.
>>
>> This can't be migrated automatically without writing your own migrations
>> and even then it won't be easy,.
>>
>> If you don't care about the current value of the reports_to field, you
>> can do this in 2 migrations - one to remove the field and another to add
>> the foreign key field. Or you can just add a drop column for the old
>> reports to field in the same migration.
>>
>> If you do care, I would probably do something like this:
>> 1. Rename the current field.
>> 2. Add the new foreign key field
>> 3. Migrate the data via a custom migration.
>>
>> Regards,
>>
>> Andréas
>>
>>
>> Den mån 12 nov. 2018 kl 17:39 skrev china <challa...@gmail.com>:
>>
>>> Hi Experts,
>>>
>>> I am trying to change the charfield to ForeignKey and I am running my
>>> code I am getting the following error if do python manage.py migrate
>>>
>>> django.db.utils.DataError: invalid input syntax for integer: "Jeff"
>>>
>>>
>>> Here is my code
>>>
>>>
>>> BEFORE
>>>
>>> ------
>>>
>>>
>>> reports_to = models.CharField(max_length=128, blank=True, null=True)
>>>
>>>
>>> in_country_manager = models.CharField(max_length=128, blank=True, null=
>>> True)
>>>
>>> After
>>> ------
>>>
>>> reports_to = models.ForeignKey("self", null=True, blank=True,
>>> related_name="employee_reports_to")
>>>
>>>
>>> Could any please help with this issue.
>>>
>>>
>>> Thanks,
>>>
>>> Karthik
>>>
>>> --
>>> 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...@googlegroups.com.
>>> To post to this group, send email to django...@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/20ca05ad-6486-489c-91fc-62adf615dee3%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/20ca05ad-6486-489c-91fc-62adf615dee3%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> 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/7414b861-7c76-4c23-8ede-c358a24c76fa%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/7414b861-7c76-4c23-8ede-c358a24c76fa%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAK4qSCf8_oDQPXBTMnPAQ3A3MMghSEh%3DdbeXt%2Bk_zPx%2BnkzNCQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to