From 7bba0fb511526c409ed41a1891c4f6a7c339d411 Mon Sep 17 00:00:00 2001 From: John Mizerek Date: Wed, 28 Jan 2026 15:11:01 -0800 Subject: [PATCH] Add one-time script to strip # from existing brand colors Co-Authored-By: Claude Opus 4.5 --- api/admin/fixBrandColors.cfm | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 api/admin/fixBrandColors.cfm diff --git a/api/admin/fixBrandColors.cfm b/api/admin/fixBrandColors.cfm new file mode 100644 index 0000000..89d627b --- /dev/null +++ b/api/admin/fixBrandColors.cfm @@ -0,0 +1,38 @@ + + + +// One-time fix: remove # prefix from BusinessBrandColor +qBefore = queryExecute(" + SELECT BusinessID, BusinessBrandColor + FROM Businesses + WHERE BusinessBrandColor LIKE :pattern +", { pattern: { value: "#%", cfsqltype: "cf_sql_varchar" } }, { datasource: "payfrit" }); + +if (qBefore.recordCount > 0) { + queryExecute(" + UPDATE Businesses + SET BusinessBrandColor = SUBSTRING(BusinessBrandColor, 2) + WHERE BusinessBrandColor LIKE :pattern + ", { pattern: { value: "#%", cfsqltype: "cf_sql_varchar" } }, { datasource: "payfrit" }); +} + +qAfter = queryExecute(" + SELECT BusinessID, BusinessBrandColor + FROM Businesses + WHERE BusinessBrandColor IS NOT NULL AND LENGTH(BusinessBrandColor) > 0 +", {}, { datasource: "payfrit" }); + +rows = []; +for (i = 1; i <= qAfter.recordCount; i++) { + arrayAppend(rows, { + "BusinessID": qAfter.BusinessID[i], + "BusinessBrandColor": qAfter.BusinessBrandColor[i] + }); +} + +writeOutput(serializeJSON({ + "OK": true, + "FIXED": qBefore.recordCount, + "CURRENT": rows +})); +