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]: Drizzle Kit migrate generating array default value wrong #1907

Closed
xkalf opened this issue Feb 20, 2024 · 2 comments
Closed

[BUG]: Drizzle Kit migrate generating array default value wrong #1907

xkalf opened this issue Feb 20, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@xkalf
Copy link

xkalf commented Feb 20, 2024

What version of drizzle-orm are you using?

0.29.2

What version of drizzle-kit are you using?

0.5.1

Describe the Bug

schema

export const lubricants = pgTable('lubricants', {
  id: serial('id').primaryKey(),
  name: varchar('name').notNull(),
  image: varchar('image').notNull(),
  description: text('description'),
  km: integer('km').notNull().default(0),
  makes: integer('makes').notNull().array().default([]),
  models: integer('models').notNull().array().default([]),
});

but generated migration is

CREATE TABLE IF NOT EXISTS "lubricants" (
	"id" serial PRIMARY KEY NOT NULL,
	"name" varchar NOT NULL,
	"image" varchar NOT NULL,
	"description" text,
	"km" integer DEFAULT 0 NOT NULL,
	"makes" integer[] DEFAULT ,
	"models" integer[] DEFAULT 
);

Expected behavior

generate sql with

"models" integer[] DEFAULT '()"
```

### Environment & setup

_No response_
@xkalf xkalf added the bug Something isn't working label Feb 20, 2024
@riccox
Copy link

riccox commented Feb 22, 2024

+1 same problem.

I am using .default(sql`array[]::varchar[]`) to work around now.
https://stackoverflow.com/a/30933366/19652493

@Angelelz
Copy link
Collaborator

Angelelz commented Mar 3, 2024

Closing as duplicate of #1003

@Angelelz Angelelz closed this as completed Mar 3, 2024
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

3 participants