-- Financial Entities: guidance text used to steer AI bank/credit-card statement extraction for
-- a given account profile (populated from a "marked" reference statement's extracted text once
-- staff upload one against the entity — see the /api/finance/ai-processing/entity-guidance
-- endpoint). Read by abos-agents on subsequent extractions for the same entity_id.
-- STRUCTURE ONLY — no data inserted here.
-- Idempotent — safe to re-run.
-- Deploy (local): mysql -u root -p db_abos_v0.1 < db/add_financial_entity_extraction_guidance.sql

USE db_abos_v0.1;

SET @col_exists = (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'dim_financial_entities' AND COLUMN_NAME = 'extraction_guidance_text');
SET @sql = IF(@col_exists = 0, 'ALTER TABLE dim_financial_entities ADD COLUMN extraction_guidance_text TEXT NULL', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
