[BUG]: Incorrect statement breakpoints cause libsql migrations to fail with SQL_NO_STATEMENT error
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 -->statement-breakpoints.
For example
- Adding constraints like autoincrements to existing columns
- Changing existing column type
The generated migration files will produce a
Error performing migration: LibsqlError: SQL_NO_STATEMENT: SQL string does not contain any statement
error when applying a migration with drizzle-orm/libsql/migrator.
Workaround:
Manually deleting the two statement breakpoints highlighted above fixes the issue.
[Note]
This bug forced me to read the autogenerated comments, which informed me that migrations for these constraints will be have to applied manually (by cloning the table, renaming it, dropping it, and renaming again). I think having an explicit warning during drizzle-kit generate:sqlite would be helpful!
Expected behavior
Migrations should apply without error
Environment & setup
No response
I'm facing an issue like that using [email protected] + [email protected].
schema before:
import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
export const users = sqliteTable("users", {
id: integer("id").primaryKey({ autoIncrement: true }).notNull(),
fullName: text("fullName").notNull(),
});
schema after:
export const users = sqliteTable("users", {
id: integer("id").primaryKey({ autoIncrement: true }).notNull(),
fullName: text("fullName").notNull(),
birthday: integer("birthday", { mode: "timestamp" }),
});
Yes.
Same issue. It has put a breakpoint solely for a comment and as a such an empty statement.
Weird thing is that I tried looking in to where the issue is or even what code creates that comment but couldn't find it.
2 way to solve this:
1.Stop adding breakpoints for comments.
2. Add to migration code to skip functionally empty sql
1 is obviously highly preferred.
If anyone could point me in the right direction I can do the work. I check this repo and the drizzle-kit-mirror repo but its in neither?
Facing this issue too on the libsql driver. Deleting the comments fixed the issue.
These comments no longer exist in the latest version.