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>
81 lines
2.5 KiB
Text
81 lines
2.5 KiB
Text
<cfsetting showdebugoutput="false">
|
|
<cfsetting enablecfoutputonly="true">
|
|
|
|
<cffunction name="apiAbort" access="public" returntype="void" output="true">
|
|
<cfargument name="payload" type="struct" required="true">
|
|
<cfcontent type="application/json; charset=utf-8">
|
|
<cfoutput>#serializeJSON(arguments.payload)#</cfoutput>
|
|
<cfabort>
|
|
</cffunction>
|
|
|
|
<cftry>
|
|
<!--- Create Stations table if it doesn't exist --->
|
|
<cfset queryExecute("
|
|
CREATE TABLE IF NOT EXISTS Stations (
|
|
StationID INT AUTO_INCREMENT PRIMARY KEY,
|
|
BusinessID INT NOT NULL,
|
|
Name VARCHAR(100) NOT NULL,
|
|
Color VARCHAR(7) DEFAULT '##666666',
|
|
SortOrder INT DEFAULT 0,
|
|
IsActive TINYINT(1) DEFAULT 1,
|
|
AddedOn DATETIME DEFAULT NOW(),
|
|
FOREIGN KEY (BusinessID) REFERENCES Businesses(BusinessID)
|
|
)
|
|
", [], { datasource = "payfrit" })>
|
|
|
|
<!--- Add StationID column to Items table if it doesn't exist --->
|
|
<cftry>
|
|
<cfset queryExecute("
|
|
ALTER TABLE Items ADD COLUMN StationID INT DEFAULT NULL
|
|
", [], { datasource = "payfrit" })>
|
|
<cfset stationColumnAdded = true>
|
|
<cfcatch>
|
|
<!--- Column likely already exists --->
|
|
<cfset stationColumnAdded = false>
|
|
</cfcatch>
|
|
</cftry>
|
|
|
|
<!--- Add foreign key if column was just added --->
|
|
<cfif stationColumnAdded>
|
|
<cftry>
|
|
<cfset queryExecute("
|
|
ALTER TABLE Items ADD FOREIGN KEY (StationID) REFERENCES Stations(StationID)
|
|
", [], { datasource = "payfrit" })>
|
|
<cfcatch></cfcatch>
|
|
</cftry>
|
|
</cfif>
|
|
|
|
<!--- Create some default stations for business 1 (In and Out Burger) if none exist --->
|
|
<cfset qCheck = queryExecute("
|
|
SELECT COUNT(*) AS cnt FROM Stations WHERE BusinessID = 1
|
|
", [], { datasource = "payfrit" })>
|
|
|
|
<cfif qCheck.cnt EQ 0>
|
|
<cfset queryExecute("
|
|
INSERT INTO Stations (BusinessID, Name, Color, SortOrder) VALUES
|
|
(1, 'Grill', '##FF5722', 1),
|
|
(1, 'Fry', '##FFC107', 2),
|
|
(1, 'Drinks', '##2196F3', 3),
|
|
(1, 'Expo', '##4CAF50', 4)
|
|
", [], { datasource = "payfrit" })>
|
|
<cfset defaultStationsCreated = true>
|
|
<cfelse>
|
|
<cfset defaultStationsCreated = false>
|
|
</cfif>
|
|
|
|
<cfset apiAbort({
|
|
"OK": true,
|
|
"MESSAGE": "Stations setup complete",
|
|
"StationColumnAdded": stationColumnAdded,
|
|
"DefaultStationsCreated": defaultStationsCreated
|
|
})>
|
|
|
|
<cfcatch>
|
|
<cfset apiAbort({
|
|
"OK": false,
|
|
"ERROR": "setup_failed",
|
|
"MESSAGE": cfcatch.message,
|
|
"DETAIL": cfcatch.detail
|
|
})>
|
|
</cfcatch>
|
|
</cftry>
|