ALTER TABLE "customer_portal_users" ADD COLUMN "last_login_at" timestamp with time zone;--> statement-breakpoint
ALTER TABLE "tenant_settings" ADD COLUMN "portal_enabled" boolean DEFAULT true NOT NULL;--> statement-breakpoint
ALTER TABLE "tenant_settings" ADD COLUMN "portal_access_method" text DEFAULT 'magic_link' NOT NULL;--> statement-breakpoint
ALTER TABLE "tenant_settings" ADD COLUMN "portal_name" text;--> statement-breakpoint
ALTER TABLE "tenant_settings" ADD COLUMN "portal_welcome_text" text;--> statement-breakpoint
ALTER TABLE "tenant_settings" ADD COLUMN "portal_primary_color_hex" text;--> statement-breakpoint
ALTER TABLE "tenant_settings" ADD COLUMN "portal_logo_url" text;--> statement-breakpoint
ALTER TABLE "tenant_settings" ADD COLUMN "portal_can_submit_tickets" boolean DEFAULT false NOT NULL;--> statement-breakpoint
ALTER TABLE "tenant_settings" ADD COLUMN "portal_can_upload_files" boolean DEFAULT false NOT NULL;--> statement-breakpoint
ALTER TABLE "tenant_settings" ADD COLUMN "portal_show_team_members" boolean DEFAULT false NOT NULL;--> statement-breakpoint
ALTER TABLE "tenant_settings" ADD COLUMN "portal_visibility" jsonb DEFAULT '{}'::jsonb;--> statement-breakpoint
ALTER TABLE "tenant_settings" ADD COLUMN "customer_default_currency" text DEFAULT 'ILS' NOT NULL;--> statement-breakpoint
ALTER TABLE "tenant_settings" ADD COLUMN "customer_auto_invite_portal" text DEFAULT 'never' NOT NULL;--> statement-breakpoint
ALTER TABLE "tenant_settings" ADD COLUMN "customer_default_portal_role" text DEFAULT 'customer_viewer' NOT NULL;--> statement-breakpoint
ALTER TABLE "tenant_settings" ADD CONSTRAINT "tenant_settings_portal_access_method_check" CHECK ("tenant_settings"."portal_access_method" IN ('magic_link', 'password'));--> statement-breakpoint
ALTER TABLE "tenant_settings" ADD CONSTRAINT "tenant_settings_customer_auto_invite_portal_check" CHECK ("tenant_settings"."customer_auto_invite_portal" IN ('never', 'on_creation', 'on_first_invoice'));--> statement-breakpoint
ALTER TABLE "tenant_settings" ADD CONSTRAINT "tenant_settings_customer_default_portal_role_check" CHECK ("tenant_settings"."customer_default_portal_role" IN ('customer_viewer'));