29 lines
889 B
PHP
29 lines
889 B
PHP
<?php
|
|
// db/migrations/add_trucks_table.php
|
|
|
|
$sql = "
|
|
CREATE TABLE IF NOT EXISTS trucks (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
user_id INT NOT NULL,
|
|
truck_type VARCHAR(120) NOT NULL,
|
|
load_capacity DECIMAL(10,2) NOT NULL,
|
|
plate_no VARCHAR(80) NOT NULL,
|
|
truck_pic_path VARCHAR(255) NULL,
|
|
registration_path VARCHAR(255) NULL,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
CONSTRAINT fk_truck_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|
|
-- Add is_company flag to truck_owner_profiles
|
|
ALTER TABLE truck_owner_profiles ADD COLUMN IF NOT EXISTS is_company BOOLEAN DEFAULT FALSE;
|
|
";
|
|
|
|
require_once __DIR__ . '/../config.php';
|
|
try {
|
|
$db = db();
|
|
$db->exec($sql);
|
|
echo "Migration applied successfully.";
|
|
} catch (Exception $e) {
|
|
echo "Error applying migration: " . $e->getMessage();
|
|
}
|