Error when trying to create a unique constraint

I have this in my schema
export const businessImage = sqliteTable("business_image", {
id: integer('id').primaryKey({ autoIncrement: true }),
businessId: integer('business_id').notNull().references(() => business.id),
imageId: integer('image_id').notNull().references(() => image.id, { onDelete: 'cascade' }),
}, (t) => ({
unq: unique().on(t.businessId, t.imageId)
}));
export const businessImage = sqliteTable("business_image", {
id: integer('id').primaryKey({ autoIncrement: true }),
businessId: integer('business_id').notNull().references(() => business.id),
imageId: integer('image_id').notNull().references(() => image.id, { onDelete: 'cascade' }),
}, (t) => ({
unq: unique().on(t.businessId, t.imageId)
}));
I'm trying to create a unique constraint on the business and image ids but get an error
Type '{ unq: UniqueConstraintBuilder; }' is not assignable to type 'SQLiteTableExtraConfig'.
Property 'unq' is incompatible with index signature.
Type 'UniqueConstraintBuilder' is not assignable to type 'IndexBuilder | CheckBuilder | ForeignKeyBuilder | PrimaryKeyBuilder | UniqueConstraintBuilder'.
Type '{ unq: UniqueConstraintBuilder; }' is not assignable to type 'SQLiteTableExtraConfig'.
Property 'unq' is incompatible with index signature.
Type 'UniqueConstraintBuilder' is not assignable to type 'IndexBuilder | CheckBuilder | ForeignKeyBuilder | PrimaryKeyBuilder | UniqueConstraintBuilder'.
I thought I may have missed something so I lifted the example from the docs but get the same error. Example:
export const composite = sqliteTable('composite_example', {
id: int('id'),
name: text('name'),
}, (t) => ({
unq: unique().on(t.id, t.name),
}));
export const composite = sqliteTable('composite_example', {
id: int('id'),
name: text('name'),
}, (t) => ({
unq: unique().on(t.id, t.name),
}));
What am I missing?
Solution:
Turns out I accidently imported unique from mysql instead on sqlite
Jump to solution
1 Reply
Solution
Matt
Matt8mo ago
Turns out I accidently imported unique from mysql instead on sqlite
Want results from more Discord servers?
Add your server