Files
sam-sales/salesmanagement/api/fix_schema.php

26 lines
1.1 KiB
PHP
Raw Normal View History

2025-12-24 09:46:07 +09:00
<?php
require_once(__DIR__ . "/../../lib/mydb.php");
$pdo = db_connect();
try {
$columns = $pdo->query("SHOW COLUMNS FROM `sales_tenant_consultations`")->fetchAll(PDO::FETCH_COLUMN);
echo "Columns: " . implode(", ", $columns) . "\n";
if (!in_array('audio_file_path', $columns)) {
$pdo->exec("ALTER TABLE `sales_tenant_consultations` ADD COLUMN `audio_file_path` varchar(500) DEFAULT NULL AFTER `log_text` ");
echo "Added audio_file_path\n";
}
if (!in_array('attachment_paths', $columns)) {
$pdo->exec("ALTER TABLE `sales_tenant_consultations` ADD COLUMN `attachment_paths` text DEFAULT NULL AFTER `audio_file_path` ");
echo "Added attachment_paths\n";
}
if (!in_array('consultation_type', $columns)) {
$pdo->exec("ALTER TABLE `sales_tenant_consultations` ADD COLUMN `consultation_type` varchar(20) DEFAULT 'text' AFTER `attachment_paths` ");
echo "Added consultation_type\n";
}
echo "Schema check completed.\n";
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}