drizzle-team / drizzle-team/drizzle-orm

Apply field changes from serial() to uuid()

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

Description

With a schema contains a field that has data type `serial`, making a change to uuid() will throw an error.

```bash
error: column "id" cannot be cast automatically to type uuid
at /Users/***/Projects/SpringBoard/Capstone2/trip-planner/node_modules/.pnpm/drizzle-kit@0.20.14/node_modules/drizzle-kit/bin.cjs:24462:21
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async PgPostgres.query (/Users/***/Projects/SpringBoard/Capstone2/trip-planner/node_modules/.pnpm/drizzle-kit@0.20.14/node_modules/drizzle-kit/bin.cjs:25423:21)
at async Command. (/Users/***/Projects/SpringBoard/Capstone2/trip-planner/node_modules/.pnpm/drizzle-kit@0.20.14/node_modules/drizzle-kit/bin.cjs:63261:9) {
length: 169,
severity: 'ERROR',
code: '42804',
detail: undefined,
hint: 'You might need to specify "USING id::uuid".',
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'tablecmds.c',
line: '11818',
routine: 'ATPrepAlterColumnType'
}
```

## Step to reproduce

```typescript
//1. original schema.ts
const user = pgTable('users', {
id: serial("id").primaryKey()
})

// 2. drizzle-kit push:ph

//3. changed schema.ts
const user = pgTable('users', {
id: uuid("id").primaryKey()
})

//4. drizzle-kit push:pg
```

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.