CREATE TABLE "Shipment" (
  "id" TEXT NOT NULL PRIMARY KEY,
  "shipmentNumber" TEXT NOT NULL,
  "salesOrderId" TEXT NOT NULL,
  "status" TEXT NOT NULL,
  "shipDate" DATETIME,
  "carrier" TEXT NOT NULL,
  "serviceLevel" TEXT NOT NULL,
  "trackingNumber" TEXT NOT NULL,
  "packageCount" INTEGER NOT NULL DEFAULT 1,
  "notes" TEXT NOT NULL,
  "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  "updatedAt" DATETIME NOT NULL,
  CONSTRAINT "Shipment_salesOrderId_fkey" FOREIGN KEY ("salesOrderId") REFERENCES "SalesOrder" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);

CREATE UNIQUE INDEX "Shipment_shipmentNumber_key" ON "Shipment"("shipmentNumber");
CREATE INDEX "Shipment_salesOrderId_createdAt_idx" ON "Shipment"("salesOrderId", "createdAt");
