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.53k stars 577 forks source link

[BUG]: drizzle-kit push throws error: UnsupportedResultException: The result contains the unsupported data type regclass. #2982

Open the-simian opened 1 week ago

the-simian commented 1 week ago

What version of drizzle-orm are you using?

0.24.2

What version of drizzle-kit are you using?

0.33.0

Describe the Bug

Running drizzle-kit push results in the error UnsupportedResultException: The result contains the unsupported data type regclass.

$ sst shell drizzle-kit push
No config path provided, using default 'drizzle.config.ts'
Reading config file '/home/the-simian/my-project/drizzle.config.ts'
[⣽] Pulling schema from database...
UnsupportedResultException: The result contains the unsupported data type regclass.
    at de_UnsupportedResultExceptionRes (/home/the-simian/my-project/node_modules/@aws-sdk/client-rds-data/dist-cjs/index.js:1015:21)
    at de_CommandError (/home/the-simian/my-project/node_modules/@aws-sdk/client-rds-data/dist-cjs/index.js:820:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /home/the-simian/my-project/node_modules/@smithy/middleware-serde/dist-cjs/index.js:35:20
    at async /home/the-simian/my-project/node_modules/drizzle-kit/bin.cjs:60552:22
    at async /home/the-simian/my-project/node_modules/drizzle-kit/bin.cjs:60310:42
    at async /home/the-simian/my-project/node_modules/drizzle-kit/bin.cjs:54122:26
    at AwsDataApiPreparedQuery.values (/home/the-simian/my-project/node_modules/src/aws-data-api/pg/session.ts:111:18)
    at AwsDataApiPreparedQuery.execute (/home/the-simian/my-project/node_modules/src/aws-data-api/pg/session.ts:61:18)
    at AwsDataApiPreparedQuery.all (/home/the-simian/my-project/node_modules/src/aws-data-api/pg/session.ts:94:18) {
  '$fault': 'client',
  '$metadata': {
    httpStatusCode: 400,
    requestId: '8e194f6c-987e-49db-b18d-d72098bce953',
    extendedRequestId: undefined,
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  }
}

Expected behavior

I expect drizzle-kit to perform as it was in the past, and push the tables to the database without generating the migration file

Environment & setup

This is calling drizzle kit with AWS RDS posgres inside of an sst shell. You can see an example if this setup here: docs: https://sst.dev/docs/start/aws/drizzle example repo: https://github.com/sst/ion/tree/dev/examples/aws-drizzle

the-simian commented 1 week ago

Here is a seemingly related issue with some troubleshooting from others https://github.com/drizzle-team/drizzle-kit-mirror/issues/544

  1. They are also using sst postgres with aws-data-api
  2. One user states that migrating past
    "drizzle-orm": "~0.30.10",
    "drizzle-kit": "~0.21.4",

I can verify this is true. Downgrading gets past this issue:

$ sst shell drizzle-kit push
drizzle-kit: v0.21.4
drizzle-orm: v0.30.10

No config path provided, using default path
Reading config file '/home/the-simian/my-project/lifeguides-application/drizzle.config.ts'
[✓] Pulling schema from database...[i] No changes detected

expresses the issue.

  1. Another user removed regclass from this query and got the command to work https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-kit/src/serializer/pgSerializer.ts#L723
the-simian commented 1 week ago

I took some time to zero in on when this broke, I think it was on the release of v0.23.0

release around 5/31

$ sst shell drizzle-kit push
drizzle-kit: v0.22.0
drizzle-orm: v0.31.0

No config path provided, using default path
Reading config file '/home/the-simian/my-project/drizzle.config.ts'
[✓] Pulling schema from database...[i] No changes detected

release around 6/29

$ sst shell drizzle-kit push
drizzle-kit: v0.22.8
drizzle-orm: v0.31.2

No config path provided, using default path
Reading config file '/home/the-simian/my-project/drizzle.config.ts'
[✓] Pulling schema from database...
[i] No changes detected

release around 7/10 💥kaboom💥

$ sst shell drizzle-kit push
drizzle-kit: v0.23.0
drizzle-orm: v0.32.0

No config path provided, using default path
Reading config file '/home/the-simian/my-project/drizzle.config.ts'
[⣯] Pulling schema from database...
UnsupportedResultException: The result contains the unsupported data type regclass.
    at de_UnsupportedResultExceptionRes (/home/the-simian/my-project/node_modules/@aws-sdk/client-rds-data/dist-cjs/index.js:1015:21)
    at de_CommandError (/home/the-simian/my-project/node_modules/@aws-sdk/client-rds-data/dist-cjs/index.js:820:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /home/the-simian/my-project/node_modules/@smithy/middleware-serde/dist-cjs/index.js:35:20
    at async /home/the-simian/my-project/node_modules/drizzle-kit/bin.cjs:60071:22
    at async /home/the-simian/my-project/node_modules/drizzle-kit/bin.cjs:64123:42
    at async /home/the-simian/my-project/node_modules/drizzle-kit/bin.cjs:57711:26
    at AwsDataApiPreparedQuery.values (/home/the-simian/my-project/node_modules/src/aws-data-api/pg/session.ts:111:18)
    at AwsDataApiPreparedQuery.execute (/home/the-simian/my-project/node_modules/src/aws-data-api/pg/session.ts:61:18)
    at AwsDataApiPreparedQuery.all (/home/the-simian/my-project/node_modules/src/aws-data-api/pg/session.ts:94:18) {
  '$fault': 'client',
  '$metadata': {
    httpStatusCode: 400,
    requestId: '62dafe04-cc01-4840-b619-9631dd065275',
    extendedRequestId: undefined,
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  }
}