-- Compatibility preflight for the historically mis-timestamped Phase 6 migration.
-- Fresh databases need only the two referenced columns until product intelligence
-- creates the canonical products table. Existing databases already have products,
-- so this is a no-op for them.
DO $$
BEGIN
  IF to_regclass('public.products') IS NULL THEN
    CREATE TABLE "products" (
      "id" TEXT NOT NULL,
      "canonicalName" TEXT NOT NULL,
      CONSTRAINT "products_pkey" PRIMARY KEY ("id")
    );
    COMMENT ON TABLE "products" IS 'toknext_phase6_placeholder';
  END IF;
END $$;
