Add one-time script to strip # from existing brand colors
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
cc96d891b2
commit
7bba0fb511
1 changed files with 38 additions and 0 deletions
38
api/admin/fixBrandColors.cfm
Normal file
38
api/admin/fixBrandColors.cfm
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<cfsetting showdebugoutput="false">
|
||||
<cfcontent type="application/json" reset="true">
|
||||
<cfscript>
|
||||
// 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
|
||||
}));
|
||||
</cfscript>
|
||||
Reference in a new issue