25 lines
835 B
PHP
25 lines
835 B
PHP
<?php
|
|
require_once(__DIR__ . "/../../lib/mydb.php");
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
try {
|
|
$pdo = db_connect();
|
|
|
|
// Ensure sort_order exists if table already created
|
|
$pdo->exec("ALTER TABLE prompt_items ADD COLUMN IF NOT EXISTS sort_order INT DEFAULT 0 AFTER current_version_id");
|
|
|
|
$sql = file_get_contents(__DIR__ . "/../schema.sql");
|
|
|
|
// Split combined SQL into individual queries for PDO if needed,
|
|
// but exec() can often handle multiple statements depending on driver config.
|
|
// For safer execution, we'll try to run it.
|
|
$pdo->exec($sql);
|
|
|
|
echo json_encode(["success" => true, "message" => "Database schema initialized successfully."]);
|
|
} catch (Exception $e) {
|
|
http_response_code(500);
|
|
echo json_encode(["success" => false, "error" => $e->getMessage()]);
|
|
}
|
|
?>
|