[
  {
    "type": "alter_table",
    "description": "Add isOptional flag to qb_account_mapping so admins can mark per-store which fields don't apply (e.g. a store that doesn't take offsite buys can mark buyPaidOffsite as N/A). Without this, MappingRepository::CRITICAL_CATEGORIES flagged every unmapped buys/sales/cogs/cash/other field as sync-blocking even when the store never logs values for them. isOptional=1 means: acknowledged unmapped, not a blocker. MappingRepository::getCompleteness() now excludes these from unmappedCritical. Idempotent via column-presence check.",
    "database": "{{store}}",
    "check_query": "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'qb_account_mapping' AND COLUMN_NAME = 'isOptional'",
    "sql": "ALTER TABLE `qb_account_mapping` ADD COLUMN `isOptional` TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'Admin-marked: 1 = N/A for this store, excluded from unmappedCritical count' AFTER `isActive`"
  }
]
