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?
nikiv.dev
nikiv.devOP•2y ago
not directly its the turso/libsql example i just changed schema instead of posts its topics did not do any new imports
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•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
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•2y ago
get this now i guess it tries to run migration again
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•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
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•2y ago
im so confused drizzle-orm is in node_modules no?
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•2y ago
its on latest but drizzle-kit fails to recognise it
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•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
nikiv.dev
nikiv.devOP•2y ago
i thought generate would fix it
nikiv.dev
nikiv.devOP•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
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•2y ago
this is prod that drizzle connects to
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•2y ago
is it safe to delete the 3 migrations?
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•2y ago
one of the migrations doesn't even have any sql inside
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•2y ago
or i should just modify this one migration and delete the other 2 ok i did that
nikiv.dev
nikiv.devOP•2y ago
modified this too
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•2y ago
im either extremely unlucky or i dont get drizzle
nikiv.dev
nikiv.devOP•2y ago
ok this works at least, no idea why package.json scripts use old versions, so weird
nikiv.dev
nikiv.devOP•2y ago
still getting this
nikiv.dev
nikiv.devOP•2y ago
dont get why
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•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?
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•2y ago
did not solve it i dont actually get why i got another migration
nikiv.dev
nikiv.devOP•2y ago
like its just duplicated
nikiv.dev
nikiv.devOP•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
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•2y ago
so i did this
nikiv.dev
nikiv.devOP•2y ago
still fails
AlcaponeYou
AlcaponeYou•2y ago
drop your tables shell into your turso instance drop table users; and topics then rerun
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•2y ago
can i start fresh like no migrations
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•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?
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•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
nikiv.dev
nikiv.devOP•2y ago
Andrii Sherman
Andrii Sherman•2y ago
before running migrations from scratch
nikiv.dev
nikiv.devOP•2y ago
its there but i cant run it it fails on some sql
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•2y ago
how do i remove __drizzle_migrations i thought i can drop table it
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•2y ago
oh ok that worked so yes cant run the server
nikiv.dev
nikiv.devOP•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
nikiv.dev
nikiv.devOP•2y ago
is code i have
Andrii Sherman
Andrii Sherman•2y ago
just remove migrations folder generate everything from scratch and it will work
nikiv.dev
nikiv.devOP•2y ago
done
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•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
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•2y ago
i gave right credentials in .env
Andrii Sherman
Andrii Sherman•2y ago
db push will push schema directly to the database
nikiv.dev
nikiv.devOP•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
nikiv.dev
nikiv.devOP•2y ago
nikiv.dev
nikiv.devOP•2y ago
oh ok that worked thank god thank you @Andrew Sherman
Andrii Sherman
Andrii Sherman•2y ago
great

Did you find this page helpful?