Planetscale UUID

Can anybody suggest how to use uuid as primary key in planetscale with drizzle orm?
23 Replies
Josh
Josh17mo ago
You have to generate the uuid yourself
Ankan
AnkanOP17mo ago
Also should I use uuid or serial key that's also a question for me
Neto
Neto17mo ago
i dont recomend using uuids they arent sortable in the same way that they were created cuid2 or ulid are two nice alternatives main difference that i can remember is: storage and limit storing string ids are more expensive in terms of storage, but they dont suffer from limitations of length a int id column tops are 4294967295 if you have the scale to worry about topping a column and not wanting to have to deal with changing the schema later, go with string ids if not, just use what you want
Ankan
AnkanOP17mo ago
Actually I was also thinking of going with string ids but was finding a way to auto implment string ids in drizzle I guess I need to do that manually
Neto
Neto17mo ago
you can probably use a default of calling a mysql function
Ankan
AnkanOP17mo ago
is there one for mysql for cuid?
Neto
Neto17mo ago
cuid probably not uuid probably there is one
Ankan
AnkanOP17mo ago
okk then it would be great using an uuid
Neto
Neto17mo ago
check if the mysql server has a generate uuid function
barry
barry17mo ago
Postgres > MySQL t3ggLove
Neto
Neto17mo ago
then you would use this one https://orm.drizzle.team/docs/indexes-constraints#default
import { sql } from "drizzle-orm";
import { int, time, mysqlTable } from "drizzle-orm/mysql-core";

const table = mysqlTable("table", {
int: int("int").default(42),
time: time("time").default(sql`cast("14:06:10" AS TIME)`), // << sql`` calling the function
});
import { sql } from "drizzle-orm";
import { int, time, mysqlTable } from "drizzle-orm/mysql-core";

const table = mysqlTable("table", {
int: int("int").default(42),
time: time("time").default(sql`cast("14:06:10" AS TIME)`), // << sql`` calling the function
});
Ankan
AnkanOP17mo ago
Actually I found PlanetScale to be a nice service but uses mysql behind the scenes. Also Neon has got its own limitations, can you recoomed some hosted service for postgresql? This one we can try out
JacobMGEvans
JacobMGEvans17mo ago
I came here to check to see if this question was moved into here and answered. Awesome to see both happened! Supabase is probably the best postgres hosted service with good DX
barry
barry17mo ago
I like neon too
Neto
Neto17mo ago
if you want a compatible
barry
barry17mo ago
cba with anything mysql
Neto
Neto17mo ago
cockroachdb as well
JacobMGEvans
JacobMGEvans17mo ago
Neon is good, there is a reason Vercel chose it lol
Ankan
AnkanOP17mo ago
I guess moving to Postgresql is kinda the right way. As I was unable to find any direct way in mysql. Thanks guys for the help. It really means a lot to me.
Neto
Neto17mo ago
glad to help
Ankan
AnkanOP17mo ago
Btw one last thing what would you suggest to use Neon or Supabase?
barry
barry17mo ago
neon
Ankan
AnkanOP17mo ago
Okk will go with that👍👍
Want results from more Discord servers?
Add your server