payfrit-api/api/ratings/setup.php
John Mizerek 1f81d98c52 Initial PHP API migration from CFML
Complete port of all 163 API endpoints from Lucee/CFML to PHP 8.3.
Shared helpers in api/helpers.php (DB, auth, request/response, security).
PDO prepared statements throughout. Same JSON response shapes as CFML.
2026-03-14 14:26:59 -07:00

38 lines
1.3 KiB
PHP

<?php
require_once __DIR__ . '/../helpers.php';
runAuth();
try {
queryTimed("
CREATE TABLE IF NOT EXISTS TaskRatings (
ID INT AUTO_INCREMENT PRIMARY KEY,
TaskID INT NOT NULL,
ByUserID INT NOT NULL,
ForUserID INT NOT NULL,
Direction VARCHAR(25) NOT NULL,
OnTime TINYINT(1) NULL,
CompletedScope TINYINT(1) NULL,
RequiredFollowup TINYINT(1) NULL,
ContinueAllow TINYINT(1) NULL,
Prepared TINYINT(1) NULL,
Respectful TINYINT(1) NULL,
WouldAutoAssign TINYINT(1) NULL,
AccessToken VARCHAR(64) NOT NULL UNIQUE,
ExpiresOn DATETIME NOT NULL,
CreatedOn DATETIME DEFAULT CURRENT_TIMESTAMP,
CompletedOn DATETIME NULL,
INDEX idx_task (TaskID),
INDEX idx_for_user (ForUserID),
INDEX idx_by_user (ByUserID),
INDEX idx_token (AccessToken)
)
", []);
$cols = queryTimed("DESCRIBE TaskRatings", []);
$colNames = array_column($cols, 'Field');
jsonResponse(['OK' => true, 'MESSAGE' => 'TaskRatings table created successfully', 'COLUMNS' => $colNames]);
} catch (Exception $e) {
jsonResponse(['OK' => false, 'ERROR' => $e->getMessage()]);
}