Fix schema check URL and improve response format

- Changed schema URL from geofeed-manager to ip-manager repo
- Added 'changes' array to schema_check response for frontend UI
- Added 'results' array to schema_apply response for frontend UI

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Purple
2026-01-18 13:34:47 +00:00
parent d113654986
commit b040337d15

View File

@@ -1958,7 +1958,7 @@ function handleSchemaCheck($db) {
jsonResponse(['error' => 'Method not allowed'], 405);
}
$schemaUrl = 'https://git.prpl.tools/PurpleComputing/geofeed-manager/raw/branch/main/database/schema.sql';
$schemaUrl = 'https://git.prpl.tools/PurpleComputing/ip-manager/raw/branch/main/database/schema.sql';
try {
// Fetch remote schema
@@ -2058,9 +2058,34 @@ function handleSchemaCheck($db) {
$hasUpdates = !empty($missingTables) || !empty($missingColumns) || !empty($missingIndexes);
// Build changes array for frontend
$changes = [];
foreach ($missingTables as $table) {
$changes[] = [
'type' => 'table',
'name' => $table,
'description' => "Create table: $table"
];
}
foreach ($missingColumns as $col) {
$changes[] = [
'type' => 'column',
'name' => $col['table'] . '.' . $col['column'],
'description' => "Add column {$col['column']} to {$col['table']}"
];
}
foreach ($missingIndexes as $idx) {
$changes[] = [
'type' => 'index',
'name' => $idx['table'] . '.' . $idx['index'],
'description' => "Add index {$idx['index']} to {$idx['table']}"
];
}
jsonResponse([
'success' => true,
'has_updates' => $hasUpdates,
'changes' => $changes,
'missing_tables' => $missingTables,
'missing_columns' => $missingColumns,
'missing_indexes' => $missingIndexes,
@@ -2087,7 +2112,7 @@ function handleSchemaApply($db) {
jsonResponse(['error' => 'Invalid CSRF token'], 403);
}
$schemaUrl = 'https://git.prpl.tools/PurpleComputing/geofeed-manager/raw/branch/main/database/schema.sql';
$schemaUrl = 'https://git.prpl.tools/PurpleComputing/ip-manager/raw/branch/main/database/schema.sql';
try {
// Fetch remote schema
@@ -2199,8 +2224,24 @@ function handleSchemaApply($db) {
'failed' => $failed
]);
// Build results array for frontend
$results = [];
foreach ($applied as $item) {
$results[] = [
'success' => true,
'description' => $item
];
}
foreach ($failed as $item) {
$results[] = [
'success' => false,
'description' => $item
];
}
jsonResponse([
'success' => true,
'results' => $results,
'applied' => $applied,
'failed' => $failed,
'message' => count($applied) > 0 ? 'Schema updates applied successfully' : 'No updates needed'