ale3xdyo
ale3xdyo
DTDrizzle Team
Created by ale3xdyo on 8/14/2023 in #help
Bug: drizzle-kit generate:pg didn't see the changes in the schema
export const productsItems = pgTable(
"products_items",
{
id: uuid("id").defaultRandom().primaryKey(),
variantName: text("variant_name"),
productId: uuid("product_id")
.notNull()
sku: text("sku").notNull(),
barcode: text("barcode"),
imageId: uuid("image_id")
deletedAt: timestamp("deleted_at", { mode: "date" }),
workspaceId: uuid("workspace_id")
.notNull()
},
(table) => ({
skuKey: uniqueIndex("sku_workspace_products_itemsuniquekey")
.on(table.sku, table.workspaceId)
.where(isNull(table.deletedAt)),
})
);
export const productsItems = pgTable(
"products_items",
{
id: uuid("id").defaultRandom().primaryKey(),
variantName: text("variant_name"),
productId: uuid("product_id")
.notNull()
sku: text("sku").notNull(),
barcode: text("barcode"),
imageId: uuid("image_id")
deletedAt: timestamp("deleted_at", { mode: "date" }),
workspaceId: uuid("workspace_id")
.notNull()
},
(table) => ({
skuKey: uniqueIndex("sku_workspace_products_itemsuniquekey")
.on(table.sku, table.workspaceId)
.where(isNull(table.deletedAt)),
})
);
Also i did some research and I saw this opened issue on github for this problem https://github.com/drizzle-team/drizzle-kit-mirror/issues/47
9 replies
DTDrizzle Team
Created by ale3xdyo on 8/14/2023 in #help
Bug: drizzle-kit generate:pg didn't see the changes in the schema
yea, I just removed the migration folder again after your message and ran drizzle-kit generate:pg and it just created the same unique index without the where clause Also it's the only schema i have declared in my project
9 replies
DTDrizzle Team
Created by ale3xdyo on 8/14/2023 in #help
Bug: drizzle-kit generate:pg didn't see the changes in the schema
After I deleted the migrations folder and rerun the generate function, the migration was not correctly generated. The where clause was missing. CREATE UNIQUE INDEX IF NOT EXISTS "sku_workspace_products_itemsuniquekey" ON "products_items" ("sku","workspace_id");--> statement-breakpoint When adding it manually in the database as: create unique index sku_workspace_products_itemsuniquekey on public.products_items using btree (sku, workspace_id) where deleted_at IS NULL; it works like a charm. So it seems that it's not seeing the where clause to generate the schema from. Am I missing something?
9 replies