-- RedefineTables PRAGMA defer_foreign_keys=ON; PRAGMA foreign_keys=OFF; CREATE TABLE "new_Product" ( "id" TEXT NOT NULL PRIMARY KEY, "title" TEXT NOT NULL, "slug" TEXT NOT NULL, "shortDescription" TEXT, "description" TEXT, "quantity" INTEGER NOT NULL DEFAULT 0, "materials" TEXT NOT NULL DEFAULT '[]', "priceCents" INTEGER NOT NULL, "imageUrl" TEXT, "published" BOOLEAN NOT NULL DEFAULT false, "inStock" BOOLEAN NOT NULL DEFAULT true, "leadTimeDays" INTEGER, "categoryId" TEXT NOT NULL, "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" DATETIME NOT NULL, CONSTRAINT "Product_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "Category" ("id") ON DELETE CASCADE ON UPDATE CASCADE ); INSERT INTO "new_Product" ("categoryId", "createdAt", "description", "id", "imageUrl", "inStock", "leadTimeDays", "materials", "priceCents", "published", "quantity", "shortDescription", "slug", "title", "updatedAt") SELECT "categoryId", "createdAt", "description", "id", "imageUrl", "inStock", "leadTimeDays", "materials", "priceCents", "published", coalesce("quantity", 0) AS "quantity", "shortDescription", "slug", "title", "updatedAt" FROM "Product"; DROP TABLE "Product"; ALTER TABLE "new_Product" RENAME TO "Product"; CREATE UNIQUE INDEX "Product_slug_key" ON "Product"("slug"); PRAGMA foreign_keys=ON; PRAGMA defer_foreign_keys=OFF;