#Auto incrementing primary key in Astro DB?

9 messages · Page 1 of 1 (latest)

quiet wadi
#

Drizzle includes a way to automatically increment your primary key using .primaryKey({ autoIncrement: true }) (see: https://orm.drizzle.team/docs/column-types/sqlite), but I'm not seeing the equivalent functionality for Astro DB's schema. Is something like this possible today?

small mango
#

primaryKey: true in your db schema is what's worked for me -

quiet wadi
small mango
#

It absolutely does for me whenever I've inserted new data 🤷‍♂️

quiet wadi
#

Maybe I found a bug, but just declaring a key as primary does not actually auto increment the key in any code I've tried

small mango
#

I see you have column.text({primaryKey:true})

#

Try column.number() maybe?

quiet wadi
#

Ah, I see. It will auto increment for numbers, but not UUIDs. That would be helpful information to include in the documentation

ripe isle
#

UUID's don't typically auto-increment, but rather are generated as a default value using some function