drizzle-team / drizzle-kit-mirror

Docs and issues repository for drizzle-kit
290 stars 17 forks source link

Trouble with Schema Changes Using `drizzle-kit push` Command in v0.23.0 #524

Open prezensy opened 2 months ago

prezensy commented 2 months ago

I'm encountering issues with the drizzle-kit push command while trying to make schema changes in my Vercel Postgres database. The problem seems related to sequence dependencies that prevent the sequences from being dropped or modified. This issue started after upgrading to drizzle-kit v0.23.0 and drizzle-orm v0.32.1.

I am using a single database to manage multiple projects, and they are differentiated by table filters. This setup complicates handling sequences and dependencies across different project schemas. Notably, when I downgrade to drizzle-kit v0.22.8, the issue is temporarily bypassed. Downgrading drizzle-orm does not produce errors, indicating that the issue may be specific to the drizzle-kit version.

Error Logs:

error: cannot drop sequence ren_businesses_id_seq because other objects depend on it
    at D:\Programming\Apps\london-fusion-food\node_modules\.pnpm\drizzle-kit@0.23.0\node_modules\drizzle-kit\bin.cjs:79476:15
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.query (D:\Programming\Apps\london-fusion-food\node_modules\.pnpm\drizzle-kit@0.23.0\node_modules\drizzle-kit\bin.cjs:121418:26)
    at async pgPush (D:\Programming\Apps\london-fusion-food\node_modules\.pnpm\drizzle-kit@0.23.0\node_modules\drizzle-kit\bin.cjs:124361:13)
    at async _Command.<anonymous> (D:\Programming\Apps\london-fusion-food\node_modules\.pnpm\drizzle-kit@0.23.0\node_modules\drizzle-kit\bin.cjs:131618:7) {
  length: 301,
  severity: 'ERROR',
  code: '2BP01',
  detail: 'default value for column id of table ren_businesses depends on sequence ren_businesses_id_seq',
  hint: 'Use DROP ... CASCADE to drop the dependent objects too.',
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'dependency.c',
  line: '1204',
  routine: 'reportDependentObjects'
}

Environment:

drizzle.config.ts:

import { defineConfig } from "drizzle-kit";

export default defineConfig({
  dialect: "postgresql",
  schema: "./db/schema.ts",
  dbCredentials: {
    url: process.env.POSTGRES_URL as string,
  },
  tablesFilter: ["lff_*"],
});
anuragxxd commented 2 months ago

Can +1 here, the command was working fine in drizzle-kit: v0.22.8

mz-makerstudio commented 2 months ago

Have you tried with the --force flag while using push command ?

Edit

I tried reproducing with --force flag and still the same issue

mz-makerstudio commented 2 months ago

I tried with v0.23.1 and looks like its working fine.

rhkdgns95 commented 1 month ago

It seems the same problem still occurs.

504