Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Check command is not working on drizzle-kit@0.21.0 #2284

Open
fellipeutaka opened this issue May 9, 2024 · 6 comments
Open

[BUG]: Check command is not working on drizzle-kit@0.21.0 #2284

fellipeutaka opened this issue May 9, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@fellipeutaka
Copy link

What version of drizzle-orm are you using?

0.30.10

What version of drizzle-kit are you using?

0.21.0

Describe the Bug

When I updated drizzle-kit to the new version (0.21.0), the check command stopped working. The first time, the response was as follows:

drizzle\meta\0000_snapshot.json is not of the latest version, please run "drizzle-kit up"

So I ran the drizzle-kit up command and got the following return:

[✓] drizzle\meta\0000_snapshot.json
Everything's fine 🐶🔥

After that, I expected it to work, but that's not the case. Executing the check command after all these procedures, the command returns the following error:

_ZodError: [
  {
    "code": "invalid_union",
    "unionErrors": [
      {
        "issues": [
          {
            "received": "6",
            "code": "invalid_literal",
            "expected": "5",
            "path": [
              "version"
            ],
            "message": "Invalid literal value, expected \"5\""
          },
          {
            "received": "postgresql",
            "code": "invalid_enum_value",
            "options": [
              "sqlite"
            ],
            "path": [
              "dialect"
            ],
            "message": "Invalid enum value. Expected 'sqlite', received 'postgresql'"
          },
          {
            "code": "unrecognized_keys",
            "keys": [
              "schema"
            ],
            "path": [
              "tables",
              "public.account"
            ],
            "message": "Unrecognized key(s) in object: 'schema'"
          },
          {
            "code": "unrecognized_keys",
            "keys": [
              "schema"
            ],
            "path": [
              "tables",
              "public.comment_upvote"
            ],
            "message": "Unrecognized key(s) in object: 'schema'"
          },
          {
            "code": "unrecognized_keys",
            "keys": [
              "schema"
            ],
            "path": [
              "tables",
              "public.comment"
            ],
            "message": "Unrecognized key(s) in object: 'schema'"
          },
          {
            "code": "unrecognized_keys",
            "keys": [
              "schema"
            ],
            "path": [
              "tables",
              "public.user"
            ],
            "message": "Unrecognized key(s) in object: 'schema'"
          },
          {
            "code": "unrecognized_keys",
            "keys": [
              "schemas"
            ],
            "path": [],
            "message": "Unrecognized key(s) in object: 'schemas'"
          }
        ],
        "name": "ZodError"
      },
      {
        "issues": [
          {
            "received": "postgresql",
            "code": "invalid_enum_value",
            "options": [
              "sqlite"
            ],
            "path": [
              "dialect"
            ],
            "message": "Invalid enum value. Expected 'sqlite', received 'postgresql'"
          },
          {
            "code": "unrecognized_keys",
            "keys": [
              "schema"
            ],
            "path": [
              "tables",
              "public.account"
            ],
            "message": "Unrecognized key(s) in object: 'schema'"
          },
          {
            "code": "unrecognized_keys",
            "keys": [
              "schema"
            ],
            "path": [
              "tables",
              "public.comment_upvote"
            ],
            "message": "Unrecognized key(s) in object: 'schema'"
          },
          {
            "code": "unrecognized_keys",
            "keys": [
              "schema"
            ],
            "path": [
              "tables",
              "public.comment"
            ],
            "message": "Unrecognized key(s) in object: 'schema'"
          },
          {
            "code": "unrecognized_keys",
            "keys": [
              "schema"
            ],
            "path": [
              "tables",
              "public.user"
            ],
            "message": "Unrecognized key(s) in object: 'schema'"
          },
          {
            "code": "unrecognized_keys",
            "keys": [
              "schemas"
            ],
            "path": [],
            "message": "Unrecognized key(s) in object: 'schemas'"
          }
        ],
        "name": "ZodError"
      }
    ],
    "path": [],
    "message": "Invalid input"
  }
]
    at get error [as error] (C:\Users\Kenji\projects\website\node_modules\.pnpm\drizzle-kit@0.21.0\node_modules\drizzle-kit\bin.cjs:2122:28)
    at snapshots.reduce.malformed (C:\Users\Kenji\projects\website\node_modules\.pnpm\drizzle-kit@0.21.0\node_modules\drizzle-kit\bin.cjs:6283:35)
    at Array.reduce (<anonymous>)
    at validateWithReport (C:\Users\Kenji\projects\website\node_modules\.pnpm\drizzle-kit@0.21.0\node_modules\drizzle-kit\bin.cjs:6269:32)
    at checkHandler (C:\Users\Kenji\projects\website\node_modules\.pnpm\drizzle-kit@0.21.0\node_modules\drizzle-kit\bin.cjs:112980:18)
    at Command.<anonymous> (C:\Users\Kenji\projects\website\node_modules\.pnpm\drizzle-kit@0.21.0\node_modules\drizzle-kit\bin.cjs:114398:3) {
  issues: [
    {
      code: 'invalid_union',
      unionErrors: [Array],
      path: [],
      message: 'Invalid input'
    }
  ],
  addIssue: [Function (anonymous)],
  addIssues: [Function (anonymous)],
  errors: [
    {
      code: 'invalid_union',
      unionErrors: [Array],
      path: [],
      message: 'Invalid input'
    }
  ]
}
drizzle\meta\0000_snapshot.json data is malformed

Expected behavior

No response

Environment & setup

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11
Binaries:
  Node: 20.12.2
  npm: N/A
  Yarn: N/A
  pnpm: 9.0.5
@fellipeutaka fellipeutaka added the bug Something isn't working label May 9, 2024
@AlonMiz
Copy link

AlonMiz commented May 13, 2024

same here

> drizzle-kit check

drizzle-kit: v0.21.1
drizzle-orm: v0.30.10

No config path provided, using default 'drizzle.config.ts'
Reading config file '/drizzle.config.ts'
_ZodError: [
  {
    "code": "invalid_union",
    "unionErrors": [
      {
        "issues": [
          {
            "received": "6",
            "code": "invalid_literal",
            "expected": "5",

@AndriiSherman
Copy link
Member

Looking into it, thanks!

@nigelnindodev
Copy link

+1, ran into the same issue.

@svemat01
Copy link

Got this issue aswell on 0.21.2. Following the stack trace, this seems to come from what I assume to be a dev test forgotten where it ignores the desired dialect from config/params and instead runs all three dialects.

Code snipped pulled from bin.cjs line 113657 - 113682 in drizzle-kit@0.21.2. I also included the up command which seems to be doing it properly.

var checkCommand = new import_commander.Command("check").option("--config <config>", `Drizzle config file path`).option("--dialect <dialect>", "Database dialect").option("--out <out>", `Output folder`).action(async (options) => {
  await printVersions();
  await assertOrmCoreVersion();
  const params = cliConfigCheck.parse(options);
  const { out, dialect: dialect7 } = await assertOutFolder(params);
  checkHandler(out, "postgresql");
  checkHandler(out, "sqlite");
  checkHandler(out, "mysql");
  console.log("Everything's fine \u{1F436}\u{1F525}");
});
var upCommand = new import_commander.Command("up").option("--config <config>", `Drizzle config file path`).option("--dialect <dialect>", "Database dialect").option("--out <out>", `Output folder`).action(async (options) => {
  await printVersions();
  await assertOrmCoreVersion();
  const params = cliConfigCheck.parse(options);
  const { out, dialect: dialect7 } = await assertOutFolder(params);
  await assertPackages("drizzle-orm");
  if (dialect7 === "postgresql") {
    upPgHandler(out);
  }
  if (dialect7 === "mysql") {
    upMysqlHandler(out);
  }
  if (dialect7 === "sqlite") {
    upSqliteHandler(out);
  }
});

@AndriiSherman Might be useful information if you're still looking into this :)

@dkmooers
Copy link

+1 here!

@TuanManhCao
Copy link

having the same issue, upgraded from

 "drizzle-kit": "^0.20.6",
 "drizzle-orm": "^0.29.1",

To

  "drizzle-orm": "0.30.10",
  "drizzle-kit": "0.21.0",

here is my drizzle.config.ts if it help

import dotenv from  "dotenv"
import type { Config } from "drizzle-kit"
dotenv.config({path: '.env.local'})
export default {
  schema: "./src/db/schema.ts",
  out: "./src/db/migrations",
  dialect: 'postgresql',
  dbCredentials: {
    url: process.env.DB_CONNECTION_URL ?? ''
  },
  migrations: {
    schema: 'public',
    table: 'migrations'
  }

} satisfies Config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants