Update: 2026-06-30 21:12:26
This commit is contained in:
@@ -17,19 +17,27 @@ try {
|
||||
|
||||
// 1. Ensure Table Exists
|
||||
$sql = "
|
||||
CREATE TABLE IF NOT EXISTS competitor_prices (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
competitor_name VARCHAR(50) NOT NULL,
|
||||
from_latitude VARCHAR(30) NOT NULL,
|
||||
from_longitude VARCHAR(30) NOT NULL,
|
||||
to_latitude VARCHAR(30) NOT NULL,
|
||||
to_longitude VARCHAR(30) NOT NULL,
|
||||
distance_km DECIMAL(8,2) NOT NULL,
|
||||
total_price DECIMAL(10,2) NOT NULL,
|
||||
price_per_km DECIMAL(8,2) NOT NULL,
|
||||
country_code VARCHAR(5) NOT NULL DEFAULT 'SY',
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
INDEX idx_competitor_country (competitor_name, country_code)
|
||||
CREATE TABLE IF NOT EXISTS `scraped_competitor_prices` (
|
||||
`id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
`task_id` varchar(100) DEFAULT NULL,
|
||||
`app_name` varchar(100) NOT NULL,
|
||||
`competitor_name` varchar(100) NOT NULL,
|
||||
`start_location` varchar(255) NOT NULL,
|
||||
`end_location` varchar(255) NOT NULL,
|
||||
`start_lat` decimal(10,7) DEFAULT NULL,
|
||||
`start_lng` decimal(10,7) DEFAULT NULL,
|
||||
`end_lat` decimal(10,7) DEFAULT NULL,
|
||||
`end_lng` decimal(10,7) DEFAULT NULL,
|
||||
`price_amount` decimal(8,2) NOT NULL,
|
||||
`price_per_km` decimal(8,2) NOT NULL,
|
||||
`currency` varchar(10) NOT NULL DEFAULT 'JOD',
|
||||
`country_code` varchar(10) NOT NULL DEFAULT 'JO',
|
||||
`scraped_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
KEY `idx_app_name` (`app_name`),
|
||||
KEY `idx_competitor_name` (`competitor_name`),
|
||||
KEY `idx_start_location` (`start_location`),
|
||||
KEY `idx_country_code` (`country_code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
";
|
||||
$con->exec($sql);
|
||||
|
||||
Reference in New Issue
Block a user