drizzle-team / drizzle-team/drizzle-orm

[BUG]: drizzle-kit push fails to recognize the existence of a default value with notNull'd columns

Open
#4,809 1 comment 8 reactions 0 assignees View on GitHub
bug bug/fixed-in-beta
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Report hasn't been filed before.

- [x] I have verified that the bug I'm about to report hasn't been filed before.

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

0.44.2

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

0.31.1

### Other packages

_No response_

### Describe the Bug

Working with sqlite. Add the following to an existing table definition in the appropriate .ts file:

```
allocationBin: real().default(0).notNull(),
```

Run drizzle-kit push.

Result:
drizzle-kit reports "You're about to add not-null allocationBin column without default value, which contains 386 items"

The proposed sql for the column is correct. However, it has determined that it must delete all data before adding the column.

Issues:
1. The error message is wrong. The column does have a default value. The computed sql shows this => 'ALTER TABLE `securities` ADD `allocationBin` real DEFAULT 0 NOT NULL;'
2. There is no reason the existing data needs to be deleted.

The only recourse for this condition is to use alternate methods to update the schema other than 'push'.

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.