drizzle-team / drizzle-team/drizzle-orm

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

Open
#2,701 10 comments 0 reactions 0 assignees View on GitHub
bug db/postgres drizzle/kit priority
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### What version of `drizzle-orm` are you using?

0.32.1

### What version of `drizzle-kit` are you using?

0.23.0

### Describe the Bug

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:**

```shell
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. (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'
}
```

**drizzle.config.ts:**

```typescript
import { defineConfig } from "drizzle-kit";

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

```

### Expected behavior

The `push` command should handle sequence dependencies gracefully or provide an option to manage them without causing errors or requiring a downgrade

### Environment & setup

- OS: Windows 11
- Node.js version: v20.13.1
- pnpm version: v9.6.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.