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
23.02k stars 551 forks source link

[BUG]: TypeError: movedTables is not iterable #2618

Open yknevenky opened 1 month ago

yknevenky commented 1 month ago

What version of drizzle-orm are you using?

"^0.32.0"

What version of drizzle-kit are you using?

"^0.23.0"

Describe the Bug

I ran introspect command and following were the error

bunx drizzle-kit introspect drizzle-kit: v0.23.0 drizzle-orm: v0.32.0

No config path provided, using default path Reading config file '/Users/some_dirs/drizzle.config.ts' Pulling from ['product'] list of schemas

Using 'pg' driver for database querying [✓] 192 tables fetched [✓] 1074 columns fetched [✓] 0 enums fetched [✓] 0 indexes fetched [✓] 285 foreign keys fetched

TypeError: movedTables is not iterable at applyPgSnapshotsDiff (/Users/some_dirs/node_modules/drizzle-kit/bin.cjs:29346:22) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async introspectPostgres (/Users/some_dirs/node_modules/drizzle-kit/bin.cjs:126156:42) at async _Command. (/Users/some_dirs/node_modules/drizzle-kit/bin.cjs:131714:7)

And the following warnings/errors were shown in the vscode Cannot find name 'nextval'. Cannot find name 'regclass'.

export const resource = our_schema.table("resource", { resource_id: uuid("resource_id"), clicked_at: date("clicked_at").defaultNow(), clicker_ip: varchar("clicker_ip"), clicked_by: varchar("clicked_by"), id: integer("id").default(nextval('ourschema.social_clicks_id_seq'::regclass)).notNull(), });

Expected behavior

No response

Environment & setup

No response

CommandLineDesign commented 1 month ago

I'm having the same issue

❯ npx drizzle-kit introspect
drizzle-kit: v0.23.0
drizzle-orm: v0.32.0

No config path provided, using default path
Reading config file '/Users/redacted/Documents/workspace/redacted/drizzle.config.ts'
Pulling from ['public'] list of schemas

Using 'pg' driver for database querying
[✓] 8  tables fetched
[✓] 46 columns fetched
[✓] 0  enums fetched
[✓] 0  indexes fetched
[✓] 11 foreign keys fetched

TypeError: movedTables is not iterable
    at applyPgSnapshotsDiff (/Users/redacted/Documents/workspace/redacted/node_modules/drizzle-kit/bin.cjs:29346:22)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async introspectPostgres (/Users/redacted/Documents/workspace/redacted/node_modules/drizzle-kit/bin.cjs:126156:42)
    at async _Command.<anonymous> (/Users/redacted/Documents/workspace/redacted/node_modules/drizzle-kit/bin.cjs:131714:7)

I did notice that the drizzle/relations.ts,drizzle/schema.ts and meta/_journal.json were created and appear to be correct however.

Sourabh-jana commented 1 month ago

I also having the same issue

$ npx drizzle-kit introspect drizzle-kit: v0.23.0 drizzle-orm: v0.32.0

No config path provided, using default path Reading config file 'C:\Users\Admin\Desktop\Evitamin\am484\evitstool_full\drizzle.config.ts' Pulling from ['public'] list of schemas

Using 'pg' driver for database querying [✓] 339 tables fetched [✓] 13792 columns fetched [✓] 16 enums fetched [✓] 68 indexes fetched [✓] 1586579 foreign keys fetched

TypeError: movedTables is not iterable at applyPgSnapshotsDiff (C:\Users\Admin\Desktop\Evitamin\am484\evitstool_full\node_modules.pnpm\drizzle-kit@0.23.0\node_modules\drizzle-kit\bin.cjs:29346:22) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async introspectPostgres (C:\Users\Admin\Desktop\Evitamin\am484\evitstool_full\node_modules.pnpm\drizzle-kit@0.23.0\node_modules\drizzle-kit\bin.cjs:126156:42) at async _Command. (C:\Users\Admin\Desktop\Evitamin\am484\evitstool_full\node_modules.pnpm\drizzle-kit@0.23.0\node_modules\drizzle-kit\bin.cjs:131714:7)

bbcriston commented 1 month ago

drizzle-kit: v0.23.0 drizzle-orm: v0.32.0

No config path provided, using default path Reading config file '/Users/cristonmascarenhas/Documents/projects/trail-backend/drizzle.config.ts' Pulling from ['public'] list of schemas

Using 'pg' driver for database querying [✓] 19 tables fetched [✓] 109 columns fetched [✓] 2 enums fetched [✓] 0 indexes fetched [✓] 14 foreign keys fetched

TypeError: movedTables is not iterable at applyPgSnapshotsDiff (/Users/cristonmascarenhas/Documents/projects/trail-backend/node_modules/.pnpm/drizzle-kit@0.23.0/node_modules/drizzle-kit/bin.cjs:29346:22) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async introspectPostgres (/Users/cristonmascarenhas/Documents/projects/trail-backend/node_modules/.pnpm/drizzle-kit@0.23.0/node_modules/drizzle-kit/bin.cjs:126156:42) at async _Command. (/Users/cristonmascarenhas/Documents/projects/trail-backend/node_modules/.pnpm/drizzle-kit@0.23.0/node_modules/drizzle-kit/bin.cjs:131714:7)

kenn commented 1 month ago

Same error with drizzle-kit introspect with the latest version.

This is one of the first steps when we migrate from Prisma to Drizzle.

SgtErnestBilko commented 1 month ago

Same problem here

antoinebassin commented 1 month ago

I run the same problem after upgrading the drizzle-orm version. I fixed it by manually updating themigrations/meta/_journal.json file from

{
  "version": "5",
  "dialect": "pg",
  ...
}

to

{
  "version": "7",
  "dialect": "postgresql",
  ...
}

Maybe the command drizzle-kit up can help

emielvangoor commented 1 month ago

Same error with drizzle-kit introspect with the latest version.

This is one of the first steps when we migrate from Prisma to Drizzle.

Same here. I want to generate a schema.ts file using introspect.

qscacheri commented 1 month ago

Same issue on latest version of drizzle/drizzle-kit

praaatik commented 1 month ago

Even I am facing the same error.

serhii-kucherenko commented 1 month ago

Having the same issue

jontybrook commented 1 month ago

Ditto here

samueldurantes commented 1 month ago

Same here

EvanGreener commented 1 month ago

Same

samueldurantes commented 1 month ago

I directly edited bin.cjs inside my node_modules to check if movedTables is declared.

OBS: I don't know if this is right, but I was able to generate the schema based on the schemas that were already present in my Postgres.

Code:
image
pschaub commented 1 month ago

This issue is reproducible for me in drizzle-kit version 0.23.0, 0.23.0-03c18d1 and 0.23.0-21045a0 but does not occur in version 0.22.8 or 0.22.9-92953ac. So downgrading the version is a temporary workaround. In all my tests drizzle-orm is on version 0.32.0 (i guess drizzle-orm is not used in this process?).

RobSchilderr commented 1 month ago

This issue is reproducible for me in drizzle-kit version 0.23.0, 0.23.0-03c18d1 and 0.23.0-21045a0 but does not occur in version 0.22.8 or 0.22.9-92953ac. So downgrading the version is a temporary workaround. In all my tests drizzle-orm is on version 0.32.0 (i guess drizzle-orm is not used in this process?).

this fixed it for me too

Eli250 commented 1 month ago

Having the same issue

drizzle-kit: v0.23.0 drizzle-orm: v0.32.1

No config path provided, using default path Reading config file '/Users/elihirwa/Desktop/Development/BAG/Projects/bag-app/drizzle.config.ts' Pulling from ['public'] list of schemas

Using 'pg' driver for database querying
[✓] 93  tables fetched
[✓] 641 columns fetched
[✓] 0   enums fetched
[✓] 1   indexes fetched
[✓] 151 foreign keys fetched

TypeError: movedTables is not iterable
    at applyPgSnapshotsDiff (/Users/elihirwa/Desktop/Development/BAG/Projects/bag-app/node_modules/drizzle-kit/bin.cjs:29346:22)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async introspectPostgres (/Users/elihirwa/Desktop/Development/BAG/Projects/bag-app/node_modules/drizzle-kit/bin.cjs:126156:42)
    at async _Command.<anonymous> (/Users/elihirwa/Desktop/Development/BAG/Projects/bag-app/node_modules/drizzle-kit/bin.cjs:131714:7)
✨  Done in 135.54s.
Bryansss1 commented 1 month ago

Same here

Deliana90 commented 1 month ago

PLEASE FIX IT BUDDY T__T

sergesteban commented 1 month ago

https://github.com/drizzle-team/drizzle-orm/issues/2618#issuecomment-2241788331

this worked for me

nielsvanrijn commented 1 month ago

Same

SuperSheykh commented 1 month ago

This issue is reproducible for me in drizzle-kit version 0.23.0, 0.23.0-03c18d1 and 0.23.0-21045a0 but does not occur in version 0.22.8 or 0.22.9-92953ac. So downgrading the version is a temporary workaround. In all my tests drizzle-orm is on version 0.32.0 (i guess drizzle-orm is not used in this process?).

Worked amazingly for me as well

AndriiSherman commented 2 weeks ago

do you see it on 0.24.0 version of drizzle-kit? Trying to reproduce it there, but no luck