Update all SQL queries, query result references, and ColdFusion code to match
the renamed database schema. Tables use plural CamelCase, PKs are all `ID`,
column prefixes stripped (e.g. BusinessName→Name, UserFirstName→FirstName).
Key changes:
- Strip table-name prefixes from all column references (Businesses, Users,
Addresses, Hours, Menus, Categories, Items, Stations, Orders,
OrderLineItems, Tasks, TaskCategories, TaskRatings, QuickTaskTemplates,
ScheduledTaskDefinitions, ChatMessages, Beacons, ServicePoints, Employees,
VisitorTrackings, ApiPerfLogs, tt_States, tt_Days, tt_AddressTypes,
tt_OrderTypes, tt_TaskTypes)
- Rename PK references from {TableName}ID to ID in all queries
- Rewrite 7 admin beacon files to use ServicePoints.BeaconID instead of
dropped lt_Beacon_Businesses_ServicePoints link table
- Rewrite beacon assignment files (list, save, delete) for new schema
- Fix FK references incorrectly changed to ID (OrderLineItems.OrderID,
Categories.MenuID, Tasks.CategoryID, ServicePoints.BeaconID)
- Update Addresses: AddressLat→Latitude, AddressLng→Longitude
- Update Users: UserPassword→Password, UserIsEmailVerified→IsEmailVerified,
UserIsActive→IsActive, UserBalance→Balance, etc.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
75 lines
2.3 KiB
Text
75 lines
2.3 KiB
Text
<cfsetting showdebugoutput="false">
|
|
<cfsetting enablecfoutputonly="true">
|
|
<cfcontent type="application/json; charset=utf-8" reset="true">
|
|
<cfheader name="Cache-Control" value="no-store">
|
|
|
|
<cfscript>
|
|
/**
|
|
* Add Schedule Fields to Categories Table
|
|
*
|
|
* Adds time-based scheduling fields:
|
|
* - ScheduleStart: TIME - Start time when category is available (e.g., 06:00:00 for breakfast)
|
|
* - ScheduleEnd: TIME - End time when category stops being available (e.g., 11:00:00)
|
|
* - ScheduleDays: VARCHAR(20) - Comma-separated list of day IDs (1=Sun, 2=Mon, etc.) or NULL for all days
|
|
*
|
|
* Run this once to migrate the schema.
|
|
*/
|
|
|
|
response = { "OK": false };
|
|
|
|
try {
|
|
// Check if columns already exist
|
|
qCheck = queryExecute("
|
|
SELECT COLUMN_NAME
|
|
FROM INFORMATION_SCHEMA.COLUMNS
|
|
WHERE TABLE_SCHEMA = 'payfrit'
|
|
AND TABLE_NAME = 'Categories'
|
|
AND COLUMN_NAME IN ('ScheduleStart', 'ScheduleEnd', 'ScheduleDays')
|
|
", {}, { datasource: "payfrit" });
|
|
|
|
existingCols = valueList(qCheck.COLUMN_NAME);
|
|
|
|
added = [];
|
|
|
|
// Add ScheduleStart if not exists
|
|
if (!listFindNoCase(existingCols, "ScheduleStart")) {
|
|
queryExecute("
|
|
ALTER TABLE Categories
|
|
ADD COLUMN ScheduleStart TIME NULL
|
|
", {}, { datasource: "payfrit" });
|
|
arrayAppend(added, "ScheduleStart");
|
|
}
|
|
|
|
// Add ScheduleEnd if not exists
|
|
if (!listFindNoCase(existingCols, "ScheduleEnd")) {
|
|
queryExecute("
|
|
ALTER TABLE Categories
|
|
ADD COLUMN ScheduleEnd TIME NULL
|
|
", {}, { datasource: "payfrit" });
|
|
arrayAppend(added, "ScheduleEnd");
|
|
}
|
|
|
|
// Add ScheduleDays if not exists
|
|
if (!listFindNoCase(existingCols, "ScheduleDays")) {
|
|
queryExecute("
|
|
ALTER TABLE Categories
|
|
ADD COLUMN ScheduleDays VARCHAR(20) NULL
|
|
", {}, { datasource: "payfrit" });
|
|
arrayAppend(added, "ScheduleDays");
|
|
}
|
|
|
|
response["OK"] = true;
|
|
response["ColumnsAdded"] = added;
|
|
response["AlreadyExisted"] = listToArray(existingCols);
|
|
response["MESSAGE"] = arrayLen(added) > 0
|
|
? "Added #arrayLen(added)# column(s): #arrayToList(added)#"
|
|
: "All columns already exist";
|
|
|
|
} catch (any e) {
|
|
response["ERROR"] = "server_error";
|
|
response["MESSAGE"] = e.message;
|
|
response["DETAIL"] = e.detail;
|
|
}
|
|
|
|
writeOutput(serializeJSON(response));
|
|
</cfscript>
|