38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../config.php';
|
|
$pdo = db();
|
|
|
|
try {
|
|
// Add target_price column to shipments if it doesn't exist
|
|
$pdo->exec("
|
|
SET @dbname = DATABASE();
|
|
SET @tablename = 'shipments';
|
|
SET @columnname = 'target_price';
|
|
SET @preparedStatement = (SELECT IF(
|
|
(
|
|
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
|
WHERE
|
|
(table_name = @tablename)
|
|
AND (table_schema = @dbname)
|
|
AND (column_name = @columnname)
|
|
) > 0,
|
|
'SELECT 1',
|
|
'ALTER TABLE shipments ADD COLUMN target_price DECIMAL(10,2) DEFAULT NULL AFTER weight_tons'
|
|
));
|
|
PREPARE alterIfNotExists FROM @preparedStatement;
|
|
EXECUTE alterIfNotExists;
|
|
DEALLOCATE PREPARE alterIfNotExists;
|
|
");
|
|
echo "Added target_price column to shipments.\n";
|
|
|
|
// Insert default pricing_model setting
|
|
$pdo->exec("
|
|
INSERT IGNORE INTO settings (setting_key, setting_value) VALUES ('pricing_model', 'percentage');
|
|
");
|
|
echo "Added pricing_model setting.\n";
|
|
|
|
} catch (PDOException $e) {
|
|
echo "Error: " . $e->getMessage() . "\n";
|
|
}
|
|
|