Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Incorrect statement breakpoints cause libsql migrations to fail with SQL_NO_STATEMENT error #1709

Open
jennnx opened this issue Dec 27, 2023 · 1 comment
Labels
bug Something isn't working drizzle-kit

Comments

@jennnx
Copy link

jennnx commented Dec 27, 2023

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.

Screenshot 2023-12-26 at 4 25 21 PM

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

@igorbrasileiro
Copy link

igorbrasileiro commented May 21, 2024

I'm facing an issue like that using drizzle-orm@0.30.10 + drizzle-kit@0.21.2.

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" }),
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working drizzle-kit
Projects
None yet
Development

No branches or pull requests

3 participants