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?
Angelelz
Angelelz192d 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
Angelelz192d 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
zhest192d 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
Angelelz192d 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
zhest192d 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
Angelelz192d ago
That's great, it would actually be great if you could submit an issue If there is none to track this
zhest
zhest192d 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
Jen
Jen144d 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
zhest135d 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
More Posts
[Solved] cannot find package 'mysql2'I've setup drizzle with a planetscale db and pushed a simple user schema, however running the pnpm dError: this.client.prepare is not a functionI am trying to build a project using Bun, Hono and Drizzle. When i am starting the project with thispg: introspect failsSo I have some tables that do not have a primary key constraint (by design) and it seems that drizzlclient connection refusedI'm using bun. I was able to get the pool connection working, but the same connection configuratioRunning migrations in server-less (edge) land??According to the docs: ``` // this will automatically run needed migrations on the database await mIs there any way to call drizzle-kit with the new node --env-file=.env argument?Hey, since node supports env files since pretty recently, it would be nice if we could ditch dotenv.enumerating tablesI have a table of possible 'statuses' for a column in my records table and would like my zod schema how to group Related Items```typescript // index.ts const coursesList = await db .select({ title: courses.title, tags: tagsNested where filter, how to not include emptyThe following almost works ``` const query = db.query.productionItem.findMany({ with: { itemStis placeholder in prepare statements deprecated!??```typescript const courses = db.query.userCourses .findMany({ where: eq(placeholder("userId")SQLite json_eachHi. I wandted to use the json_each function in sqlite, but I dont think the query is building correcForeign key truncated for being too long?Hi, I have multiple warnings / notices: `{ severity_local: 'NOTICE', severity: 'NOTICE', codedrizzle-zod with custom typesI have defined opaque types in my application and have implemented those in the drizzle schema (awesUsing transactions in automated testing like JestI have a testing set-up as follows: 1. Start postgres container 2. Apply migrations to db 3. Jest tTypeScript complaining about using a spread operator in partial select queryTypeScript complaining about me using a spread operator in partial select query. I have the followiUnable to read error message when inserting withdb.insert().values()Hey there, i am using visual studio code and am developing with nuxt3. I am trying to insert an objehow to add new driver to drizzle?what is the procedure of adding a new driver to drizzle orm?`drizzle-kit --custom` is not giving me a blank migration fileI'm doing the following: ```sh drizzle-kit generate:pg --custom ``` But it's not giving me a blankNo id returned (mysql2)``` async function create(data: NewBusiness) { return client.insert(business).values(data) } ``` Studio when using Turso `Error: Cannot find module 'better-sqlite3'`Error when trying to start Studio and push `Error: Cannot find module 'better-sqlite3'`