MySQL UUID as PK
I am unable to get a PK setup which has a default UUID value.
I have
in my table schema
But it creates a migration query that literally adds the literal string 'UUID()' in the field
but running this in MySQL directly, the table is created with a PK that does default to an actual UUID string value
6 Replies
Oh, and I'm using Drizzle ORM 0.28.2 and Kit 0.19.13
MySQL column types - DrizzleORM
Drizzle ORM | %s
I did
and
These don't work.
MySQL has a UUID() method, but as mentioned, right now, despite using the magic
sql
operator, the literal string value of UUID()
is being inserted, not an actual UUIDYou need to check the version of Mysql you are using. It may or may not support the use of non deterministic default values
See the accepted answer here: https://stackoverflow.com/questions/46134550/mysql-set-default-id-uuid
Stack Overflow
MySQL set default id UUID
I'm trying to create tables in a database that has an id field that will populate the id with an UUID by default.
I tried something like:
CREATE TABLE FOO (
id CHAR(36) PRIMARY KEY DEFAULT uuid...
Maybe you can try it this way