Skip to content

[BUG]: drizzle-kit generates schema with invalid JavaScript syntax in default values #4121

@gyenabubakar

Description

@gyenabubakar

Report hasn't been filed before.

  • I have verified that the bug I'm about to report hasn't been filed before.

What version of drizzle-orm are you using?

0.39.3

What version of drizzle-kit are you using?

0.30.4

Other packages

No response

Describe the Bug

I was following the Supabase guide while using a local Supabase setup. My drizzle.config.ts file is as follows:

import 'dotenv/config';
import { defineConfig } from 'drizzle-kit';

export default defineConfig({
  out: './src/lib/server/drizzle',
  schema: './src/lib/server/drizzle/schema.ts',
  dialect: 'postgresql',
  schemaFilter: ['public', 'auth'],
  dbCredentials: {
    url: process.env.PRIVATE_SUPABASE_DB_URL!,
  },
});

Upon running drizzle-kit pull, the generated schema contains invalid JavaScript syntax for default() values. Specifically, default() is generated with an unclosed single quote:

phoneChange: text("phone_change").default('),
phoneChangeToken: varchar("phone_change_token", { length: 255 }).default('),

This causes a syntax error in the application.

Steps to Reproduce

  1. Set up a local Supabase instance.
  2. Use the provided drizzle.config.ts configuration.
  3. Run drizzle-kit generate.
  4. Observe that the generated schema has default() values with an unclosed single quote.

Expected Behavior

Drizzle should generate valid JavaScript syntax, ensuring that default() values are correctly formatted (e.g., default('') instead of default(')).

Additional Context

  • Database Engine: PostgreSQL (Supabase)
  • Monorepo: No
  • Runtime: Node.js 20.11.2
  • TypeScript Version: 5.7.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions