FG
๐Ÿ’ป Software๐Ÿ—„๏ธ Databases

[BUG]:Drizzle-Kit 0.19.0 Fails to Generate Migrations

Fresh3 days ago
Mar 14, 20260 views
Confidence Score62%
62%

Problem

What version of `drizzle-orm` are you using? 0.27.0 What version of `drizzle-kit` are you using? 0.19.0 Describe the Bug I was using Drizzle Kit version of 0.18.1 and generating migrations with this command. `drizzle-kit generate:pg --config=drizzle.config.ts` As soon as I updated drizzle-kit to 0.19.0 version this command doesn't work anymore throwing the error `TypeError [ERR_INVALID_RETURN_PROPERTY_VALUE]: Expected a url string to be returned for the "url" from the "drizzle-kit/loader.mjs 'resolve'" function but got instance of String.` Expected behavior _No response_ Environment & setup _No response_

Error Output

error

`TypeError [ERR_INVALID_RETURN_PROPERTY_VALUE]: Expected a url string to be returned for the "url" from the "drizzle-kit/loader.mjs 'resolve'" function but got instance of String.`

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix โ€“ Awaiting Verification

Update Drizzle-Kit Configuration for Version 0.19.0 Compatibility

Medium Risk

The error occurs because the `drizzle-kit` version 0.19.0 expects a URL string format for the 'url' property in its configuration, whereas previous versions may have accepted a different format. This change in expected return type leads to the TypeError when the `generate:pg` command is executed.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Check Current Configuration

    Review the existing `drizzle.config.ts` file to identify the format of the 'url' property. Ensure that it is correctly formatted as a URL string.

    typescript
    const config = { url: 'postgres://user:password@localhost:5432/mydb' };
  2. 2

    Update URL Property

    Modify the 'url' property in your `drizzle.config.ts` file to ensure it returns a valid URL string. If it is currently a String instance, convert it to a proper URL string format.

    typescript
    const config = { url: new URL('postgres://user:password@localhost:5432/mydb') };
  3. 3

    Install Compatible Dependencies

    Ensure that all dependencies are compatible with `drizzle-kit` version 0.19.0. Run the following command to update your packages.

    bash
    npm install drizzle-kit@0.19.0 drizzle-orm@0.27.0
  4. 4

    Run Migration Command

    After updating the configuration and dependencies, re-run the migration generation command to verify that the issue is resolved.

    bash
    drizzle-kit generate:pg --config=drizzle.config.ts
  5. 5

    Test Migration Output

    Check the output of the migration generation command to ensure that migrations are created successfully without errors.

    bash
    ls migrations/

Validation

Confirm that the migration command runs without throwing the TypeError and that the expected migration files are generated in the specified directory.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

drizzleormtypescriptbugdrizzle/kit