drizzle-team / drizzle-kit-mirror

Docs and issues repository for drizzle-kit
288 stars 16 forks source link

BUG: `drizzle-kit generate` TypeError: Right-hand side of 'instanceof' is not an object #434

Open dinwwwh opened 1 month ago

dinwwwh commented 1 month ago

This issue occurs on "drizzle-kit": "0.22.0-407e2e6" and when the column uses default fn.

  const Notes = schema.table('notes', {
    id: uuid('id')
      .notNull()
      .primaryKey()
      .default(sql`uuid_generate_v4()`), //---- this line

    url: varchar('url', { length: 256 }).notNull().unique(),
    title: varchar('title', { length: 256 }),
    description: varchar('description', { length: 1024 }),
    markdown: varchar('markdown', { length: 65536 }).notNull(),

    createdAt: timestamp('created_at')
      .notNull()
      .defaultNow(), //---- this line
    updatedAt: timestamp('updated_at')
      .notNull()
      .defaultNow() //---- this line
      .$onUpdate(() => new Date()), 
  })

full error

pnpm drizzle-kit generate

drizzle-kit: v0.22.0
drizzle-orm: v0.31.0-7a05232

No config path provided, using default 'drizzle.config.ts'
Reading config file '/home/dinwwwh/noteask/apps/tenant-api/drizzle.config.ts'
TypeError: Right-hand side of 'instanceof' is not an object
    at is (/home/dinwwwh/noteask/node_modules/.pnpm/drizzle-orm@0.31.0-7a05232_@cloudflare+workers-types@4.20240512.0_@neondatabase+serverless@0.9.3/node_modules/src/entity.ts:17:6)
    at /home/dinwwwh/noteask/node_modules/.pnpm/drizzle-kit@0.22.0-407e2e6/node_modules/drizzle-kit/bin.cjs:15797:44
    at Array.forEach (<anonymous>)
    at generatePgSnapshot (/home/dinwwwh/noteask/node_modules/.pnpm/drizzle-kit@0.22.0-407e2e6/node_modules/drizzle-kit/bin.cjs:15758:17)
    at serializePg (/home/dinwwwh/noteask/node_modules/.pnpm/drizzle-kit@0.22.0-407e2e6/node_modules/drizzle-kit/bin.cjs:16998:14)
    at async preparePgMigrationSnapshot (/home/dinwwwh/noteask/node_modules/.pnpm/drizzle-kit@0.22.0-407e2e6/node_modules/drizzle-kit/bin.cjs:17124:26)
    at async prepareAndMigratePg (/home/dinwwwh/noteask/node_modules/.pnpm/drizzle-kit@0.22.0-407e2e6/node_modules/drizzle-kit/bin.cjs:22445:48)
    at async Command.<anonymous> (/home/dinwwwh/noteask/node_modules/.pnpm/drizzle-kit@0.22.0-407e2e6/node_modules/drizzle-kit/bin.cjs:121802:5)
mattfysh commented 1 month ago

not sure how this works but it does :shrug: edit the bin.cjs file in drizzle-kit

#!/usr/bin/env node
"use strict";
+require('drizzle-orm');
dinwwwh commented 1 month ago

Thank you, @mattfysh! It works for me! 😊