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]: Array default in migrations are wrong #2621

Closed
cybercoder-naj opened this issue Jul 12, 2024 · 1 comment
Closed

[BUG]: Array default in migrations are wrong #2621

cybercoder-naj opened this issue Jul 12, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@cybercoder-naj
Copy link

cybercoder-naj commented Jul 12, 2024

What version of drizzle-orm are you using?

0.31.2

What version of drizzle-kit are you using?

0.22.8

Describe the Bug

For the given schema in typescript:

export const users = schema.table('users', {
  id: text('id').primaryKey(),
  /* removed for brevity */
  dietaryRestrictions: text('dietary_restrictions')
    .array()
    .notNull()
    .default([]),
  allergies: text('allergies').array().notNull().default([]),
  meals: boolean('meals').array().notNull().default([false, false, false])
});

the migration schema provided was:

CREATE TABLE IF NOT EXISTS "auth"."users" (
    "id" text PRIMARY KEY NOT NULL, 
    --> removed for brevity
    "dietary_restrictions" text[] DEFAULT  NOT NULL,
    "allergies" text[] DEFAULT  NOT 
    "meals" boolean[] DEFAULT false,false,false NOT NULL,
);

The default values given for arrays are not correct.

Expected behavior

The migration sql must output:

CREATE TABLE IF NOT EXISTS "auth"."users" (
    "id" text PRIMARY KEY NOT NULL,
    --> removed for brevity
    "dietary_restrictions" text[] DEFAULT '{}' NOT NULL,
    "allergies" text[] DEFAULT '{}' NOT NULL,
    "pronouns" text NOT NULL,
    "meals" boolean[] DEFAULT '{false,false,false}' NOT NULL
);

Environment & setup

bun v1.1.18, linux x86

@AndriiSherman
Copy link
Member

Should be fixed in drizzle-kit0.24.0
Please check release notes before updating

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

2 participants