-- Add new optional fields to orders table
ALTER TABLE "public"."orders" ADD COLUMN "orderDate" TIMESTAMP(3);
ALTER TABLE "public"."orders" ADD COLUMN "startTime" TEXT;
ALTER TABLE "public"."orders" ADD COLUMN "endTime" TEXT;

-- Update existing orders with default values based on existing docDt
UPDATE "public"."orders" SET 
  "orderDate" = "docDt",
  "startTime" = '09:00',
  "endTime" = '17:00'
WHERE "orderDate" IS NULL;

-- Make docNo optional (remove NOT NULL constraint)
ALTER TABLE "public"."orders" ALTER COLUMN "docNo" DROP NOT NULL;