3e7fa45ed6
Add journal entry preview, human-readable account names, auto-apply VAT, fallback template suggestions, example prompts, invoice match comparison, and batch result feedback. Also includes user-description-match extension, describe/batch-describe API routes, improved AI categorization with multi- suggestion support, and template embedding search. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
24 lines
983 B
SQL
24 lines
983 B
SQL
-- Migration: user_description_matching
|
|
-- Adds source tracking, user description text, and template_id to mapping_rules
|
|
-- to support user-description-based transaction matching.
|
|
--
|
|
-- Safe migration: all new columns have defaults or are nullable,
|
|
-- so existing rows remain valid.
|
|
|
|
-- 1. Add source column to track rule origin
|
|
ALTER TABLE public.mapping_rules
|
|
ADD COLUMN IF NOT EXISTS source TEXT NOT NULL DEFAULT 'auto'
|
|
CHECK (source IN ('auto', 'user_description', 'system'));
|
|
|
|
-- 2. Add user_description column to store the user's plain-language text
|
|
ALTER TABLE public.mapping_rules
|
|
ADD COLUMN IF NOT EXISTS user_description TEXT;
|
|
|
|
-- 3. Add template_id column to store the confirmed booking template
|
|
ALTER TABLE public.mapping_rules
|
|
ADD COLUMN IF NOT EXISTS template_id TEXT;
|
|
|
|
-- 4. Index for efficient upsert-on-merchant lookup by source
|
|
CREATE INDEX IF NOT EXISTS idx_mapping_rules_user_merchant_source
|
|
ON public.mapping_rules (user_id, merchant_pattern, source);
|