drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
24.82k stars 658 forks source link

[BUG]: `drizzle-kit push --force` fails if `__old_push_table` doesn't exist #2789

Open nickBes opened 3 months ago

nickBes commented 3 months ago

What version of drizzle-orm are you using?

0.33.0

What version of drizzle-kit are you using?

0.24.0

Describe the Bug

Every time I run drizzle-kit push --force when the previous __old_push table doesn't exist, with the next error: LibsqlError: SQLITE_UNKNOWN: SQLite error: no such table: main.__old_push_parties

I've logged the statements that drizzle-kit executes for the migration, and apparently in performs DROP TABLE __old_push_table for the first command. I believe that the reason this migration fails because the previous statement lacks IF EXISTS.

Expected behavior

I'd expect it not to fail when I simply want to push my changes without caring about the old data.

Environment & setup

I'm running that on arch with node@20, but I have that script on a github runner with ubuntu-latest which uses oven-sh/setup-bun@v2 and it also fails with the same error.

This is how my drizzle.config.ts looks like:

import { defineConfig } from "drizzle-kit";

export default defineConfig({
  driver: "turso",
  dbCredentials: {
    authToken: process.env["DB_API_TOKEN"],
    url: String(process.env["DB_HOST"]),
  },
  schema: ["./src/schema.ts"],
  dialect: "sqlite",
});
CaffeinatedTech commented 3 months ago

Yeah, if you rename a table, or even a column it just gets out of sync even if there is no data in the table.