24 lines
1.0 KiB
PHP
24 lines
1.0 KiB
PHP
<?php
|
|
require 'db/config.php';
|
|
$db = db();
|
|
|
|
$queries = [
|
|
"ALTER TABLE invoices ADD COLUMN IF NOT EXISTS transaction_no VARCHAR(50) DEFAULT NULL AFTER id",
|
|
"ALTER TABLE invoices ADD COLUMN IF NOT EXISTS is_pos TINYINT(1) DEFAULT 0",
|
|
"ALTER TABLE invoices ADD COLUMN IF NOT EXISTS discount_amount DECIMAL(15,3) DEFAULT 0",
|
|
"ALTER TABLE invoices ADD COLUMN IF NOT EXISTS loyalty_points_earned DECIMAL(15,3) DEFAULT 0",
|
|
"ALTER TABLE invoices ADD COLUMN IF NOT EXISTS loyalty_points_redeemed DECIMAL(15,3) DEFAULT 0",
|
|
"ALTER TABLE invoices ADD COLUMN IF NOT EXISTS created_by INT(11) DEFAULT NULL",
|
|
"ALTER TABLE payments ADD COLUMN IF NOT EXISTS transaction_id INT(11) DEFAULT NULL", // To keep link if needed
|
|
"ALTER TABLE invoices MODIFY COLUMN status ENUM('paid','unpaid','partially_paid','refunded','cancelled') DEFAULT 'unpaid'"
|
|
];
|
|
|
|
foreach ($queries as $q) {
|
|
try {
|
|
$db->exec($q);
|
|
echo "Executed: $q\n";
|
|
} catch (Exception $e) {
|
|
echo "Error executing $q: " . $e->getMessage() . "\n";
|
|
}
|
|
}
|