Is it possible to insert records with CUIDs from m...
# orm-help
k
Is it possible to insert records with CUIDs from mysql, while automatically generating the id?
r
Directly from MySQL? I don’t think so as
cuid
is a Prisma specific helper.
k
That's unfortunate. I'm trying to move data between tables and thought of doing that on the database level. Is it efficient though to do it from Prisma?
r
Yeah, if you’re using
nApi
then it should be.
k
Thank you.
🙌 1
@Ryan With nApi enabled, the script took two long hours to finish! Any ways to speed this up?
I run 100 promises concurrently everytime
r
How many records?
k
more than a million, but after running the script more get created I think the script generated nearly 3 million records
so 1 million gets converted to 3 million
to give you a little bit context
in our Prisma 1 db, we saved insights like favorites and ignores in join tables, saving only ids of the user and the item
in our Prisma 2 db, we refactored the model
now we have a separate Insight table
it has an enum with multiple types
like ignores, ignores_unique, favorite, favorite_unique, etc
the old model didnt have createdAt, the new one does in addition to other info
so converting from old to new, I'm checking if the insight is there first, creating it if not then checking if it has the unique type of the same type, ignores? => check ignores_unique if not, I create a unique insight
and so on, and so forth
to check if an insight exists, I use a count query
@Ryan
r
Have you tried it without Prisma? Does it take the same amount of time?
k
It's not possible for me without prisma, as records inserted need a CUID