Replies: 3 comments
-
did you find a solution? |
Beta Was this translation helpful? Give feedback.
0 replies
-
In case you are using pg, this should work. export const template = pgTable(
"post",
{
id: text("id")
.primaryKey()
.$defaultFn(() => crypto.randomUUID()),
authorId: text("authorId")
.notNull()
.references(() => users.id, {onDelete: "cascade"}),
},
(table) => {
return {
// authorIdIdx: sql`CREATE INDEX "authorIdIdx" ON "post" USING HASH ("authorIdId");`,
authorIdIdx: index().using(
"hash",
table.authorIdId,
)
};
}
); |
Beta Was this translation helpful? Give feedback.
0 replies
-
Update. You're currently using the old syntax for defining indexes in (tbl) => [
index("author_id_idx").using("hash").on(tbl.authorId),
] |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I want to create an index on a table in my Drizzle schema with one caveat, I want the index to be using the HASH index type.
However, when I am looking into the Drizzle documentation I see that there may or may not be support for this already, if the documentation is accurate, I would of course prefer to use its methods instead of writing custom SQL. Link to Drizzle documentation
The documentation states that only the name and on() params are currently supported. However, the example immediately below the statement says otherwise. Additionally, the typescript types mentioned in the example are defined in the codebase. And lastly, why does the using method take a SQL statement as the input and not a string (e.g. "b-tree", "hash" etc.)? Anyone from the Drizzle ORM community who could give me some guidance on this? Thanks.
My own attempt using custom SQL so far.
Beta Was this translation helpful? Give feedback.
All reactions