1170, "BLOB/TEXT column

94 views
Skip to first unread message

Sammi Singh

unread,
Feb 19, 2016, 4:30:46 PM2/19/16
to Django users
Hi,

I'm new wot Django and stuck with below error when run migrate. Any suggestions??

django.db.utils.OperationalError: (1170, "BLOB/TEXT column 'id' used in key specification without a key length")


Here is my code:

class Steps(models.Model):

    author = models.ForeignKey(User)

#    id = models.TextField(primary_key=True)

    id = models.CharField(primary_key=True, max_length = 32)

    text = models.TextField()

    status = models.TextField()

    step_id = models.TextField(null=True)

    release_id = models.TextField(null=True)

    region = models.TextField(null=True)

    # Time is a rhinocerous

    updated = models.DateTimeField(auto_now=True)

    created = models.DateTimeField(auto_now_add=True)


    class Meta:

        ordering = ['created']


    def __unicode__(self):

        return self.text+' - '+self.author.username


class UserConfig(models.Model):

    author = models.ForeignKey(User)

#    id = models.TextField(primary_key=True)

    id = models.CharField(primary_key=True, max_length = 32)

    co_range = models.TextField()

    tu_range = models.TextField()

    st_range = models.TextField()

    de_host = models.TextField()

    in_host1 = models.TextField()

    in_host2 = models.TextField()

    in_host3 = models.TextField()

    co_host = models.TextField()

    vp_name = models.TextField()


    # Time is a rhinocerous

    updated = models.DateTimeField(auto_now=True)

    created = models.DateTimeField(auto_now_add=True)


    class Meta:

        ordering = ['created']


    def __unicode__(self):

        return self.text+' - '+self.author.username


Regards
Sammi

Luis Zárate

unread,
Feb 19, 2016, 6:30:08 PM2/19/16
to django...@googlegroups.com
Check your migrations, I think you use TextField the first time, run makemigrations  and create the initial migrations, before you run migrate django raise a exception so you change it for CharField and run makemigrations  a second time and create the correction in the 002 migration but the initial migration has the problem so when you run migrate again the problem persist.
> --
> 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/7f1a4f9c-7a75-4202-ac3b-2e8f369ea2e6%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

--
"La utopía sirve para caminar" Fernando Birri



Reply all
Reply to author
Forward
0 new messages