CREATE TABLE "sumit_webhook_events" (
	"id" text PRIMARY KEY NOT NULL,
	"event_type" text NOT NULL,
	"payload" jsonb NOT NULL,
	"received_at" timestamp with time zone DEFAULT now() NOT NULL,
	"processed_at" timestamp with time zone
);
--> statement-breakpoint
ALTER TABLE "purchases" ADD COLUMN "sumit_payment_id" integer;--> statement-breakpoint
ALTER TABLE "purchases" ADD COLUMN "sumit_vendor_doc_id" integer;--> statement-breakpoint
ALTER TABLE "purchases" ADD COLUMN "sumit_vendor_doc_number" integer;--> statement-breakpoint
ALTER TABLE "purchases" ADD COLUMN "sumit_vendor_receipt_url" text;--> statement-breakpoint
ALTER TABLE "purchases" ADD COLUMN "sumit_platform_doc_id" integer;--> statement-breakpoint
ALTER TABLE "purchases" ADD COLUMN "sumit_platform_doc_number" integer;--> statement-breakpoint
ALTER TABLE "purchases" ADD COLUMN "sumit_platform_receipt_url" text;--> statement-breakpoint
ALTER TABLE "purchases" ADD COLUMN "platform_fee_amount_agorot" integer;--> statement-breakpoint
ALTER TABLE "purchases" ADD COLUMN "platform_fee_pct" integer;--> statement-breakpoint
ALTER TABLE "vendors" ADD COLUMN "sumit_company_id" integer;--> statement-breakpoint
ALTER TABLE "vendors" ADD COLUMN "sumit_api_key_enc" text;--> statement-breakpoint
ALTER TABLE "vendors" ADD COLUMN "sumit_terminal_active" boolean DEFAULT false NOT NULL;--> statement-breakpoint
ALTER TABLE "vendors" ADD COLUMN "sumit_bank_code" integer;--> statement-breakpoint
ALTER TABLE "vendors" ADD COLUMN "sumit_branch_code" integer;--> statement-breakpoint
ALTER TABLE "vendors" ADD COLUMN "sumit_account_last4" text;--> statement-breakpoint
ALTER TABLE "vendors" ADD COLUMN "sumit_onboarded_at" timestamp with time zone;--> statement-breakpoint
CREATE INDEX "purchases_sumit_payment_id_idx" ON "purchases" USING btree ("sumit_payment_id");--> statement-breakpoint
CREATE INDEX "purchases_pending_payment_idx" ON "purchases" USING btree ("payment_status","created_at") WHERE payment_status = 'PENDING';--> statement-breakpoint
CREATE UNIQUE INDEX "vendors_sumit_company_id_uidx" ON "vendors" USING btree ("sumit_company_id") WHERE sumit_company_id IS NOT NULL;