Get issue trying to run libsql/turso example

on this project https://github.com/learn-anything/learn-anything/tree/main/db If I run pnpm run start, I get this:
GitHub
learn-anything/db at main · learn-anything/learn-anything
Organize world's knowledge, explore connections and curate learning paths - learn-anything/db at main · learn-anything/learn-anything
79 Replies
Andrii Sherman
Andrii Sherman•2y ago
cc @Dan Kochetov
Dan
Dan•2y ago
are you trying to import something from drizzle-orm/expressions?
nikivi
nikiviOP•2y ago
not directly its the turso/libsql example i just changed schema instead of posts its topics did not do any new imports
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
ok see this but i did not add it
Dan
Dan•2y ago
an outdated example probably this should be imported from drizzle-orm
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
get this now i guess it tries to run migration again
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
im very confused why it thinks its outdated i guess it takes a global one i dont get on which line this error happens table topics already exists 🤔
Andrii Sherman
Andrii Sherman•2y ago
drizzle-kit latest is 0.19.2 Not 0.18.0
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
im so confused drizzle-orm is in node_modules no?
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
its on latest but drizzle-kit fails to recognise it
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
it would be nice if the drizzle-kit was standalone and didn't depend on external things because I don't know where it is getting drizzle-orm from, it should be latest version in node_modules but its failing dont know how to fix it tried rm -rf node_modules and pnpm i too or maybe im missing something pnpm add -g drizzle-orm ok it has a dep on global drizzle-orm
nikivi
nikiviOP•2y ago
i thought generate would fix it
nikivi
nikiviOP•2y ago
yea i dont know what throws this error trying to read through the turso/libsql example I guess it tries to create the table it feels like its trying to run migrations that it already run going to seed the db for now, not really sure how to preceed from the error maybe delete all the migrations files and start again? 🤔 it could be applied migration manually myself? as it was not working for me not sure how to reset things from the error it seems its libsql i mentioned it in turso discord i don't really know how to unblock from this i can try wipe migrations and run start again
AlcaponeYou
AlcaponeYou•2y ago
Do .tables Tables already exist? The SQLite generated output should use IF NOT EXISTS
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
this is prod that drizzle connects to
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
is it safe to delete the 3 migrations?
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
one of the migrations doesn't even have any sql inside
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
or i should just modify this one migration and delete the other 2 ok i did that
nikivi
nikiviOP•2y ago
modified this too
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
im either extremely unlucky or i dont get drizzle
nikivi
nikiviOP•2y ago
ok this works at least, no idea why package.json scripts use old versions, so weird
nikivi
nikiviOP•2y ago
still getting this
nikivi
nikiviOP•2y ago
dont get why
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
stack trace does not say the line i assume its during migrate like why would it try create topics table
The SQLite generated output should use IF NOT EXISTS
@alcaponeyou where should I add this?
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
did not solve it i dont actually get why i got another migration
nikivi
nikiviOP•2y ago
like its just duplicated
nikivi
nikiviOP•2y ago
seems drizzle is confused
AlcaponeYou
AlcaponeYou•2y ago
drizzle should have aded that but it doesn't add "verbose: true" in your drizzle.confg.ts file
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
so i did this
nikivi
nikiviOP•2y ago
still fails
AlcaponeYou
AlcaponeYou•2y ago
drop your tables shell into your turso instance drop table users; and topics then rerun
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
can i start fresh like no migrations
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
i.e. i removed migrations folder now so i want a fresh schema deployed drizzle-kit generate:sqlite so I can run this now?
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
i guess i need to db-push it now? how can i do it
Andrii Sherman
Andrii Sherman•2y ago
you need to use migrate() function from drizzle-orm remove __drizzle_migrations also
nikivi
nikiviOP•2y ago
Andrii Sherman
Andrii Sherman•2y ago
before running migrations from scratch
nikivi
nikiviOP•2y ago
its there but i cant run it it fails on some sql
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
how do i remove __drizzle_migrations i thought i can drop table it
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
oh ok that worked so yes cant run the server
nikivi
nikiviOP•2y ago
GitHub
learn-anything/db at main · learn-anything/learn-anything
Organize world's knowledge, explore connections and curate learning paths - learn-anything/db at main · learn-anything/learn-anything
nikivi
nikiviOP•2y ago
is code i have
Andrii Sherman
Andrii Sherman•2y ago
just remove migrations folder generate everything from scratch and it will work
nikivi
nikiviOP•2y ago
done
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
i need to db-push it i think to turso
Andrii Sherman
Andrii Sherman•2y ago
db push has nothing with generate process
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
i gave right credentials in .env
Andrii Sherman
Andrii Sherman•2y ago
db push will push schema directly to the database
nikivi
nikiviOP•2y ago
so it should apply it to prod turso but it doesnt ok so drizzle-kit generate:sqlite only changed schema to local sqlite? shouldnt it be prod turso as i have provided the url and auth token
Andrii Sherman
Andrii Sherman•2y ago
it's nor changing schema it;s just generating an sql migration file you need to apply it to database then using migrate() function
nikivi
nikiviOP•2y ago
nikivi
nikiviOP•2y ago
oh ok that worked thank god thank you @Andrew Sherman
Andrii Sherman
Andrii Sherman•2y ago
great
Want results from more Discord servers?
Add your server