(1170, u“BLOB/TEXT column 'user_id' used in key specification without a key length”)

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP

(1170, u“BLOB/TEXT column 'user_id' used in key specification without a key length”)



I am using a MySQL db in my flask app. I am using SQLAlchemy with pymysql too. The app is deployed on a web server(linux based - specifically Ubuntu). I am trying to apply migrations using flask-migrate but I keep on getting the error



(1170, u"BLOB/TEXT column 'user_id' used in key specification without a key length")



My primary keys look like this:


id = db.Column(db.String(32),default=lambda: str(uuid4().hex), primary_key=True)



The specific table where this error arises is an association table: The code is


user_association_table = db.Table('association', db.Model.metadata,
db.Column('user_id', db.String(32), db.ForeignKey('user.id')),
db.Column('article_id', db.String(32), db.ForeignKey('article.id'))
)



I have seen similar questions but they address how to fix it using MySQL directly. Since I have minimal control of how mysql is generated, how can I bypass this error?




1 Answer
1



Turns out the original MySQL db that I was trying to apply migrations to was not fully up to date with the size of the primary key --> db.String(32) Deleting and recreating the database made migrations work just fine.
If the database has data then it would be more painful to recreate the database without losing data.


--> db.String(32)






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

Executable numpy error

Trying to Print Gridster Items to PDF without overlapping contents

Mass disable jenkins jobs