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.
Migration failed
LibsqlError: SQL_NO_STATEMENT: SQL string does not contain any statement
...
code: 'SQL_NO_STATEMENT',
[cause]: [ResponseError: SQL string does not contain any statement] {
code: 'SQL_NO_STATEMENT',
proto: {
message: 'SQL string does not contain any statement',
code: 'SQL_NO_STATEMENT'
}
}
}
 ELIFECYCLE  Command failed with exit code 1.
Migration failed
LibsqlError: SQL_NO_STATEMENT: SQL string does not contain any statement
...
code: 'SQL_NO_STATEMENT',
[cause]: [ResponseError: SQL string does not contain any statement] {
code: 'SQL_NO_STATEMENT',
proto: {
message: 'SQL string does not contain any statement',
code: 'SQL_NO_STATEMENT'
}
}
}
 ELIFECYCLE  Command failed with exit code 1.
Above is from the migration script.
main().catch((e) => {
console.error('Migration failed');
console.error(e);
process.exit(1);
});
main().catch((e) => {
console.error('Migration failed');
console.error(e);
process.exit(1);
});
Additionally, when I try to do push via drizzle-kit, I get the following:
Error: Cannot find module 'better-sqlite3'
Error: Cannot find module 'better-sqlite3'
However, I am using Turso, so my migration script uses libsql, and importing as such.
import { drizzle } from 'drizzle-orm/libsql';
import { drizzle } from 'drizzle-orm/libsql';
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
Angelelz
Angelelz13mo ago
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
Angelelz
Angelelz13mo ago
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
zhest
zhestOP13mo ago
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.
/*
SQLite does not support "Changing existing column type" out of the box, we do not generate automatic migration for that, so it has to be done manually
Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
https://www.sqlite.org/lang_altertable.html
https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3

Due to that we don't generate migration automatically and it has to be done manually
*/
/*
SQLite does not support "Changing existing column type" out of the box, we do not generate automatic migration for that, so it has to be done manually
Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
https://www.sqlite.org/lang_altertable.html
https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3

Due to that we don't generate migration automatically and it has to be done manually
*/
The other problem with better-sqlite is that it conflicts with my auth adapter via lucia.
 WARN  Issues with peer dependencies found
.
└─┬ @lucia-auth/adapter-sqlite 2.0.0
└── ✕ unmet peer better-sqlite3@^8.0.0: found 9.0.0
 WARN  Issues with peer dependencies found
.
└─┬ @lucia-auth/adapter-sqlite 2.0.0
└── ✕ unmet peer better-sqlite3@^8.0.0: found 9.0.0
Angelelz
Angelelz13mo ago
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
zhest
zhestOP13mo ago
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"
Angelelz
Angelelz13mo ago
That's great, it would actually be great if you could submit an issue If there is none to track this
zhest
zhestOP13mo ago
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
Hmph
Hmph12mo ago
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...
zhest
zhestOP11mo ago
thanks! I ended up getting push to work, and have been using that to develop... I should probably try migrating more often
Want results from more Discord servers?
Add your server