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 generate didn't add CREATE EXTENSION IF NOT EXISTS vector; #3929

Open
1 task done
bap2pecs opened this issue Jan 10, 2025 · 5 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@bap2pecs
Copy link

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.38.3

What version of drizzle-kit are you using?

0.30.1

Other packages

No response

Describe the Bug

my scheme.ts

import { index, integer, pgTable, varchar, text, timestamp, vector, json } from "drizzle-orm/pg-core";
import { EMBEDDING_DIMENSIONS } from "../embedding/consts";

export const myEmbeddingTable = pgTable(
  "my_embedding",
  {
  id: integer().primaryKey().generatedAlwaysAsIdentity(),
  name: varchar({ length: 255 }).notNull(),
  content: text("content").notNull(),
  metadata: json("metadata"),
  embedding: vector("embedding", {
    dimensions: EMBEDDING_DIMENSIONS
    }),
    created_at: timestamp("created_at").notNull().defaultNow(),
    updated_at: timestamp("updated_at").notNull().defaultNow(),
  },
  (table) => [
    index("embedding_index").using("hnsw", table.embedding.op("vector_cosine_ops"))
  ]
);

then I run drizzle generate, it created a .sql file but it's missing

CREATE EXTENSION IF NOT EXISTS vector;

at the first line which will cause error if I run drizzle migrate:

[⣷] applying migrations...error: type "vector" does not exist
@bap2pecs bap2pecs added the bug Something isn't working label Jan 10, 2025
@krahul-evs
Copy link

We are on the following versions and are facing the same issue:

  • drizzle-orm: 0.38.1
  • drizzle-kit: 0.30.0

@kenedyolisi
Copy link

kenedyolisi commented Jan 13, 2025

the IF NOT EXISTS clause has been dropped since drizzle-kit 0.30.0. See https://github.com/drizzle-team/drizzle-orm/releases/tag/drizzle-kit%400.30.0

@kenedyolisi
Copy link

the IF NOT EXISTS clause has been dropped since drizzle-kit 0.30.0 see https://github.com/drizzle-team/drizzle-orm/releases/tag/drizzle-kit%400.30.0

@bap2pecs
Copy link
Author

the IF NOT EXISTS clause has been dropped since drizzle-kit 0.30.0 see https://github.com/drizzle-team/drizzle-orm/releases/tag/drizzle-kit%400.30.0

thanks! so what should be generated here to resolve the error:

[⣷] applying migrations...error: type "vector" does not exist

@EthanITA
Copy link

EthanITA commented Jan 15, 2025

the IF NOT EXISTS clause has been dropped since drizzle-kit 0.30.0 see https://github.com/drizzle-team/drizzle-orm/releases/tag/drizzle-kit%400.30.0

thanks! so what should be generated here to resolve the error:

[⣷] applying migrations...error: type "vector" does not exist

You need to install the pg_vector exntension for postgres. Generally it's bundled
https://github.com/pgvector/pgvector

If the command is not generated, before running the migration, edit your .sql and add the command at the top of the file
"CREATE EXTENSION IF NOT EXISTS vector;"

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

4 participants