Migration Failed LibsqlError
I had migrated prior, done a lot of schema work, and then did a drizzle-generate, worked fine and I migrated, but got the following error.
Above is from the migration script.
Additionally, when I try to do push via drizzle-kit, I get the following:
However, I am using Turso, so my migration script uses libsql, and importing as such.
I can not really get past this error and only found it after doing a lot of
schema.ts
work. Is my only course of action to backtrack my schema.ts
file and see where the issue is or is there an easier way to trouble shoot migration errors that I am not familiar with?9 Replies
You are running through several issues. The first one id your migration file probably has a statement breakpoint where it shouldn't. Take a look here: https://orm.drizzle.team/kit-docs/conf#sql-breakpoints
Configuration files - DrizzleORM
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind
So it's very likely that drizzle kit put a breakpoint where it was not necessary. Can you share the migration file that got generated?
The sqlite3 issue is an issue I've seen before with turso, unfortunately I can't help much because the kit hasn't been open sourced yet. But if I were you I would try and install better-sqlite3 because it looks like it's a dependency for drizzle-kit
hey @Angelelz thanks for responding. I see you doing a lot of community support all by yourself, so you're a rockstar by my book.
I did some more work looking through my files, cleaning up my schema/etc. breakpoints look fine to me, I do have this note from the migration file, but am having trouble tracking down where I am changing column types.
The other problem with better-sqlite is that it conflicts with my auth adapter via lucia.
The other problem with better-sqlite is that it conflicts with my auth adapter via lucia.
I bet you there is a statement breakpoint right after that comment. I think you should be safe deleting that breakpoint and run the migration again.
For your other problem, you can try installing the version that matches the one that lucia wants
thanks, I do want to keep looking for the issue though, as I want to fix things so it is "automatic/out of the box"
That's great, it would actually be great if you could submit an issue
If there is none to track this
ok so I did get push to work, but still have some issue, but at least I was able to get tables loaded into turso
migrate throws a table already exists error
push throws a FOREIGN KEY constraint failed
Didn't see an open issue (and still running into this issue), so I opened one here: https://github.com/drizzle-team/drizzle-orm/issues/1709
GitHub
[BUG]: Incorrect statement breakpoints cause libsql migrations to f...
What version of drizzle-orm are you using? 0.29.1 What version of drizzle-kit are you using? 0.20.7 Describe the Bug Generating migration files for libsql will sometimes produce incorrect -->sta...
thanks! I ended up getting push to work, and have been using that to develop... I should probably try migrating more often