drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
21.47k stars 486 forks source link

[BUG]: runnning introspect:pg adds unused import functions to schema.ts #2467

Open izu12ki opened 3 weeks ago

izu12ki commented 3 weeks ago

What version of drizzle-orm are you using?

0.30.10

What version of drizzle-kit are you using?

0.20.18

Describe the Bug

When i execute "drizzle-kit introspect:pg", it adds unused import functions to schema.ts.

The unused import functions

import { pgTable, pgSchema, index, uniqueIndex, varchar, time, boolean, timestamp, date, serial, text, doublePrecision, integer, bigint } from "drizzle-orm/pg-core"
  import { sql } from "drizzle-orm"

Out of the above, pgTable and sql aren't used in the schema.ts file. Thus my linter warns me for unused imports.

Expected behavior

Not adding unused import function.

Environment & setup

Packages i use

"dependencies": { "@fastify/cors": "^9.0.1", "drizzle-orm": "^0.30.10", "fastify": "^4.27.0", "firebase": "^10.12.1", "firebase-admin": "^12.1.1", "fluent-json-schema": "^4.2.1", "postgres": "^3.4.4" }, "devDependencies": { "@biomejs/biome": "1.7.3", "@fastify/swagger": "^8.14.0", "@fastify/swagger-ui": "^3.0.0", "@types/node": "^20.12.10", "@types/pg": "^8.11.6", "drizzle-kit": "^0.20.18", "drizzle-valibot": "^0.2.0", "i": "^0.3.7", "pg": "8.11.5", "pino-pretty": "^11.0.0", "tsx": "^4.9.3", "typescript": "^5.4.5" }, updating pg to 8.11.6 didn't change the result

command I run from package.json:

"scripts": { "pull": "pnpm --env-file=.env drizzle-kit introspect:pg", }

drizzle.config.ts:

import { defineConfig } from "drizzle-kit";
export default defineConfig({
  driver: 'pg',
  schema: "./src/schema.ts",
  out: "./drizzle",
  dbCredentials: {
    connectionString: process.env.DB_URL ?? ''
  },
  schemaFilter: ["public", "sales"],
});