-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmigrations_v3.sql
More file actions
21 lines (18 loc) · 1.03 KB
/
Copy pathmigrations_v3.sql
File metadata and controls
21 lines (18 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
-- ============================================================
-- InboxIQ v3 Migrations — Run in Supabase SQL Editor
-- ============================================================
-- Fix webhooks table to match backend API
-- (v2 had events[] + enabled; v3 uses event TEXT + is_active)
ALTER TABLE webhooks ADD COLUMN IF NOT EXISTS event TEXT DEFAULT 'all';
ALTER TABLE webhooks ADD COLUMN IF NOT EXISTS is_active BOOLEAN DEFAULT TRUE;
-- Auto-assign rules (org-level rules to auto-assign emails to members)
CREATE TABLE IF NOT EXISTS auto_assign_rules (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
org_id UUID REFERENCES organizations(id) ON DELETE CASCADE,
condition_type TEXT NOT NULL CHECK (condition_type IN ('sender_domain', 'category', 'priority_gte')),
condition_value TEXT NOT NULL,
assign_to_user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE,
is_active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMPTZ DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_auto_assign_rules_org_id ON auto_assign_rules(org_id);