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>
69 lines
2.1 KiB
Text
69 lines
2.1 KiB
Text
<cfsetting showdebugoutput="false">
|
|
<cfsetting enablecfoutputonly="true">
|
|
<cfcontent type="application/json; charset=utf-8" reset="true">
|
|
|
|
<cfscript>
|
|
// Creates ScheduledTaskDefinitions table if not exists
|
|
// Public endpoint for setup
|
|
|
|
function apiAbort(required struct payload) {
|
|
writeOutput(serializeJSON(payload));
|
|
abort;
|
|
}
|
|
|
|
try {
|
|
// Create ScheduledTaskDefinitions table
|
|
queryExecute("
|
|
CREATE TABLE IF NOT EXISTS ScheduledTaskDefinitions (
|
|
ID INT AUTO_INCREMENT PRIMARY KEY,
|
|
BusinessID INT NOT NULL,
|
|
Name VARCHAR(100) NOT NULL,
|
|
TaskCategoryID INT NULL,
|
|
TaskTypeID INT NULL,
|
|
Title VARCHAR(255) NOT NULL,
|
|
Details TEXT NULL,
|
|
CronExpression VARCHAR(100) NOT NULL,
|
|
ScheduleType VARCHAR(20) DEFAULT 'cron',
|
|
IntervalMinutes INT NULL,
|
|
IsActive BIT(1) DEFAULT b'1',
|
|
LastRunOn DATETIME NULL,
|
|
NextRunOn DATETIME NULL,
|
|
CreatedOn DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
CreatedByUserID INT NULL,
|
|
INDEX idx_business (BusinessID),
|
|
INDEX idx_active_next (IsActive, NextRunOn)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
|
|
", [], { datasource: "payfrit" });
|
|
|
|
// Add new columns if they don't exist (for existing tables)
|
|
try {
|
|
queryExecute("
|
|
ALTER TABLE ScheduledTaskDefinitions
|
|
ADD COLUMN ScheduleType VARCHAR(20) DEFAULT 'cron' AFTER CronExpression
|
|
", [], { datasource: "payfrit" });
|
|
} catch (any e) {
|
|
// Column likely already exists
|
|
}
|
|
|
|
try {
|
|
queryExecute("
|
|
ALTER TABLE ScheduledTaskDefinitions
|
|
ADD COLUMN IntervalMinutes INT NULL AFTER ScheduleType
|
|
", [], { datasource: "payfrit" });
|
|
} catch (any e) {
|
|
// Column likely already exists
|
|
}
|
|
|
|
apiAbort({
|
|
"OK": true,
|
|
"MESSAGE": "ScheduledTaskDefinitions table created/verified with interval support"
|
|
});
|
|
|
|
} catch (any e) {
|
|
apiAbort({
|
|
"OK": false,
|
|
"ERROR": "server_error",
|
|
"MESSAGE": e.message
|
|
});
|
|
}
|
|
</cfscript>
|