drizzle-team / drizzle-team/drizzle-orm

[BUG]: tries to add enum value twice, etc

Open
#4,345 3 comments 0 reactions 0 assignees View on GitHub
db/postgres drizzle/kit enhancement priority
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?

```
drizzle-orm: v0.39.3

```

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

```
drizzle-kit: v0.30.4

```

### Other packages

```
drizzle-zod: specifier: ^0.6.1 version: 0.6.1(drizzle-orm@0.39.3(@neondatabase/serverless@0.10.4)(@types/pg@8.11.11)(pg@8.13.3)(postgres@3.4.5))(zod@3.24.2)
```

### Describe the Bug

the automatically generated sql for a migration includes

```sql
ALTER TYPE "public"."account_status_enum" ADD VALUE 'suspended' BEFORE 'deleted';
ALTER TYPE "public"."account_status_enum" ADD VALUE 'suspended';
```

the full error was:

```console
Warning You are about to execute current statements:

ALTER TYPE "public"."account_status_enum" ADD VALUE 'probation' BEFORE 'deleted';
ALTER TYPE "public"."account_status_enum" ADD VALUE 'banned' BEFORE 'deleted';
ALTER TYPE "public"."account_status_enum" ADD VALUE 'suspended' BEFORE 'deleted';
ALTER TYPE "public"."account_status_enum" ADD VALUE 'suspended';
ALTER TABLE "client_user_info" ALTER COLUMN "marriage_pref" SET DEFAULT '[]';
ALTER TABLE "client_user_info" ALTER COLUMN "children_pref" SET DEFAULT '[]';
ALTER TABLE "client_user_info" ALTER COLUMN "gender_pref" SET DEFAULT '[]';
ALTER TABLE "client_user_info" ALTER COLUMN "age_pref" SET DEFAULT '[]';
ALTER TABLE "credentials" ALTER COLUMN "search_vector" SET DEFAULT ''::tsvector;
ALTER TABLE "credentials" ALTER COLUMN "embedding" SET DEFAULT null;
ALTER TABLE "dd_users" ALTER COLUMN "search_vector" SET DEFAULT ''::tsvector;
ALTER TABLE "dd_users" ALTER COLUMN "embedding" SET DEFAULT null;
ALTER TABLE "file_uploads" ALTER COLUMN "permissions" SET DEFAULT '[]';
ALTER TABLE "accredited_institutions" ALTER COLUMN "google_places" SET DEFAULT '[]';
ALTER TABLE "accredited_institutions" ALTER COLUMN "search_vector" SET DEFAULT ''::tsvector;
ALTER TABLE "accredited_institutions" ALTER COLUMN "embedding" SET DEFAULT null;
ALTER TABLE "leads" ALTER COLUMN "search_vector" SET DEFAULT ''::tsvector;
ALTER TABLE "user_keywords" ALTER COLUMN "keyword_value" SET DEFAULT '{"value":null}';
ALTER TABLE "user_keywords" ALTER COLUMN "search_vector" SET DEFAULT ''::tsvector;
ALTER TABLE "user_keywords" ALTER COLUMN "embedding" SET DEFAULT null;
ALTER TABLE "otp_tokens" ALTER COLUMN "http_headers" SET DEFAULT '{}';
ALTER TABLE "user_invitations" ALTER COLUMN "roles" SET DEFAULT '[]';
ALTER TABLE "user_keyword_relations" ALTER COLUMN "search_vector" SET DEFAULT ''::tsvector;
ALTER TABLE "user_keyword_relations" ALTER COLUMN "embedding" SET DEFAULT null;
ALTER TABLE "query_embedding_cache" ALTER COLUMN "search_vector" SET DEFAULT ''::tsvector;
ALTER TABLE "search_index_table" ALTER COLUMN "search_vector" SET DEFAULT ''::tsvector;
ALTER TABLE "search_index_table" ALTER COLUMN "embedding" SET DEFAULT null;
ALTER TABLE "skills" ALTER COLUMN "default_val" SET DEFAULT '{"value":1}';
ALTER TABLE "skills" ALTER COLUMN "search_vector" SET DEFAULT ''::tsvector;
ALTER TABLE "skills" ALTER COLUMN "embedding" SET DEFAULT null;
ALTER TABLE "tags" ALTER COLUMN "tag_value" SET DEFAULT '{"value":null}';
ALTER TABLE "tags" ALTER COLUMN "search_vector" SET DEFAULT ''::tsvector;
ALTER TABLE "error_tracking" ALTER COLUMN "search_vector" SET DEFAULT ''::tsvector;
ALTER TABLE "ttl_table" ALTER COLUMN "expires_at" SET DEFAULT '2025-03-30T19:40:48.480Z';
ALTER TABLE "update_history" ALTER COLUMN "blob" SET DEFAULT '{}';
ALTER TABLE "user_credentials" ALTER COLUMN "search_vector" SET DEFAULT ''::tsvector;
ALTER TABLE "user_credentials" ALTER COLUMN "embedding" SET DEFAULT null;
ALTER TABLE "user_meet_events" ALTER COLUMN "duration_seconds" SET DEFAULT -1;
ALTER TABLE "oauth1_tokens" ALTER COLUMN "scopes" SET DEFAULT '[]';
ALTER TABLE "user_activity" ALTER COLUMN "more_related_user_ids" SET DEFAULT '[]';
ALTER TABLE "user_activity" ALTER COLUMN "more_related_clerk_user_ids" SET DEFAULT '[]';
ALTER TABLE "user_settings" ALTER COLUMN "setting_value" SET DEFAULT '{}';
ALTER TABLE "oauth2_tokens" ALTER COLUMN "scopes" SET DEFAULT '[]';
ALTER TABLE "user_skills" ALTER COLUMN "sub_category" SET DEFAULT '{"value":null}';
ALTER TABLE "user_skills" ALTER COLUMN "applicable_creds" SET DEFAULT '[]';
ALTER TABLE "email_subscriptions" ALTER COLUMN "subscription_preferences" SET DEFAULT '{"newsletter": true, "product_updates": true, "promotions": true, "event_invitations": true, "educational": true, "announcements": true, "digest": true}'::jsonb;
ALTER TABLE "email_subscriptions" ALTER COLUMN "search_vector" SET DEFAULT ''::tsvector;
ALTER TABLE "blog_posts" ALTER COLUMN "search_vector" SET DEFAULT ''::tsvector;
ALTER TABLE "coach_user_info" ALTER COLUMN "gender_pref" SET DEFAULT '[]';
ALTER TABLE "coach_user_info" ALTER COLUMN "marriage_pref" SET DEFAULT '[]';
ALTER TABLE "coach_user_info" ALTER COLUMN "children_pref" SET DEFAULT '[]';
ALTER TABLE "coach_user_info" ALTER COLUMN "age_pref" SET DEFAULT '[]';
ALTER TABLE "coach_user_info" ALTER COLUMN "petsPreference" SET DEFAULT '[]';
ALTER TABLE "comments" ALTER COLUMN "search_vector" SET DEFAULT ''::tsvector;

error: enum label "suspended" already exists
at /Users/alexandermills/codes/dd/dd-next-1/node_modules/.pnpm/pg-pool@3.7.1_pg@8.13.3/node_modules/pg-pool/index.js:45:11
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async Object.query (/Users/alexandermills/codes/dd/dd-next-1/node_modules/.pnpm/drizzle-kit@0.30.4/node_modules/drizzle-kit/bin.cjs:66575:26)
at async pgPush (/Users/alexandermills/codes/dd/dd-next-1/node_modules/.pnpm/drizzle-kit@0.30.4/node_modules/drizzle-kit/bin.cjs:70117:13)
at async Object.handler (/Users/alexandermills/codes/dd/dd-next-1/node_modules/.pnpm/drizzle-kit@0.30.4/node_modules/drizzle-kit/bin.cjs:79124:9)
at async run (/Users/alexandermills/codes/dd/dd-next-1/node_modules/.pnpm/drizzle-kit@0.30.4/node_modules/drizzle-kit/bin.cjs:78381:7) {
length: 95,
severity: 'ERROR',
code: '42710',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'pg_enum.c',
line: '264',
routine: 'AddEnumLabel'
}
```

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.