How can I add a Prefix Index?

I migrated from Prisma, and I have a column with varchar(2000) which I indexed with @@index([columnName(length: 191)]) but the introspection schema didn't seem to recognize the index length:
columnNameIdx: index("TableName_columnName_idx").on(table.columnName)
columnNameIdx: index("TableName_columnName_idx").on(table.columnName)
is there a workaround to set the index length? maybe with raw sql? Thank you in advance.
4 Replies
Andrii Sherman
Andrii Sherman17mo ago
Not for now, but we will have a support for it As a workaround you can just create this index manually in database and leave //TODO comment in current schema to add this index right after we will add support for it
jeffc
jeffc12mo ago
Has support for prefix indexes been added yet? I'm encountering an issue that requires a prefix index to be defined
[✓] Your SQL migration file ➜ src/drizzle/0004_sticky_doctor_strange.sql 🚀
reading ./src/drizzle/meta/_journal.json
89 | this.connection.release();
90 | }
91 |
92 | query(query, params) {
93 | const c = this.connection;
94 | const localErr = new Error();
^
error: Specified key was too long; max key length is 3072 bytes
code: "ER_TOO_LONG_KEY"
[✓] Your SQL migration file ➜ src/drizzle/0004_sticky_doctor_strange.sql 🚀
reading ./src/drizzle/meta/_journal.json
89 | this.connection.release();
90 | }
91 |
92 | query(query, params) {
93 | const c = this.connection;
94 | const localErr = new Error();
^
error: Specified key was too long; max key length is 3072 bytes
code: "ER_TOO_LONG_KEY"
Yaakov
Yaakov7mo ago
@Andrew Sherman Any update on this?
Andrii Sherman
Andrii Sherman7mo ago
not yet, we had a few other priorities, but it's on track
Want results from more Discord servers?
Add your server