drizzle-team / drizzle-team/drizzle-orm
[BUG]: drizzle-kit pull in v1.0.0-beta.20 fails on fresh Nile DB with invalid internal value for Enum
- 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?
1.0.0-beta.20
### What version of `drizzle-kit` are you using?
1.0.0-beta.20
### Other packages
_No response_
### Describe the Bug
I am using Drizzle ORM v1 beta with NileDB and drizzle-kit pull fails during introspection on a fresh database.
Environment:
framework: Nextjs 14 Monorepo
language: Typescript (v.5.9.3)
runtime: Node 20.x
database: NileDB / Postgres
command: npx drizzle-kit pull
Config:
drizzle.config.ts
```
import { loadEnvConfig } from '@next/env';
loadEnvConfig(process.cwd());
import { defineConfig } from 'drizzle-kit';
export default defineConfig({
out: './drizzle',
schema: [
'./src/server/modules/**/schema.ts',
'./src/server/modules/**/*.schema.ts',
'./src/server/modules/**/enums.ts',
'./src/server/db/enums.ts',
'./src/server/db/relations.ts',
],
dialect: 'postgresql',
casing: 'snake_case',
dbCredentials: {
url: process.env.NILEDB_URL!,
},
// Nile tables live in public and users schemas.
schemaFilter: ['public', 'users'],
extensionsFilters: ['postgis'],
});
```
src\server\db\index.ts
```
import { Pool } from 'pg';
import { drizzle } from 'drizzle-orm/node-postgres';
import { fullSchema } from './schema';
import { relations } from './relations';
const pool = new Pool({
connectionString: process.env.NILEDB_URL!,
max: 10, // Maximum connections in pool
idleTimeoutMillis: 30000, // 30s
connectionTimeoutMillis: 5000, // 5s
});
pool.on('error', (err) => {
console.error('Unexpected error on idle client:', err);
});
export const db = drizzle({
client: pool,
relations,
schema: fullSchema,
casing: 'snake_case',
});
```
Expected:
- drizzle-kit pull should introspect the database and generate migration sql and json files.
- a schema file for nile built-in tenant and tenant_user tables and a relation file were also getting generated before the beta branch
Actual:
It fails immediately during introspection, before any tables are fetched:
invalid internal value for enum: 2
```
PS C:\Users\...\project-name> npx drizzle-kit pull
No config path provided, using default 'drizzle.config.ts'
Reading config file 'C:\Users\...\project-name\drizzle.config.ts'
Using 'pg' driver for database querying
[⣷] 0 tables fetching
[⣷] 0 columns fetching
[⣷] 0 enums fetching
[⣷] 0 indexes fetching
[⣷] 0 foreign keys fetching
[⣷] 0 policies fetching
[⣷] 0 check constraints fetching
[⣷] 0 views fetching
[✗] Error during introspection:
invalid internal value for enum: 2
Error: invalid internal value for enum: 2
at C:\Users\...\project-name\node_modules\drizzle-kit\bin.cjs:233397:12
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.query (C:\Users\...\project-name\node_modules\drizzle-kit\bin.cjs:233392:13)
at async Promise.all (index 3)
at async fromDatabase$3 (C:\Users\...\project-name\node_modules\drizzle-kit\bin.cjs:237829:56)
at async fromDatabaseForDrizzle$3 (C:\Users\...\project-name\node_modules\drizzle-kit\bin.cjs:238576:15)
```
Notes:
This happens on a fresh test database, and also on my existing production database.
My app Enums are string-backed TypeScript Enums.
The database contains Nile built-in schemas/tables in public and users, plus app tables in public.
Debug steps tried:
- I deleted my node modules and did fresh install, the error persists
- I simplified the drizzle config to the minimum required Nile setup and that didn't solve it
- Finally used previously pulled files from before the beta migration, used **drizzle-kit up** to update to the new format and then ran **drizzle-kit generate** for my app's schemas and successfully ran **drizzle-kit migrate**
- After that first successful migration, no new migrations or pushes worked and i have to create a new db for each schema change
Minimal reproduction:
Run npx drizzle-kit pull against a fresh Nile database with the config above.
Contributor guide
Assessment
This issue has not been assessed yet.