-- DRIVERS
CREATE TABLE drivers (
    id SERIAL PRIMARY KEY,
    full_name VARCHAR(100),
    is_online BOOLEAN DEFAULT FALSE,
    online_since TIMESTAMP,
    status VARCHAR(20) DEFAULT 'free',
    vip_level INT DEFAULT 0,
    advertising_level INT DEFAULT 0,
    is_active BOOLEAN DEFAULT TRUE
);

-- DRIVER LOCATIONS
CREATE TABLE driver_locations (
    driver_id INT PRIMARY KEY,
    latitude DECIMAL(9,6),
    longitude DECIMAL(9,6),
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- ORDERS
CREATE TABLE orders (
    id SERIAL PRIMARY KEY,
    client_lat DECIMAL(9,6),
    client_lng DECIMAL(9,6),
    status VARCHAR(20) DEFAULT 'searching',
    current_driver_id INT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- ATTEMPTS
CREATE TABLE order_driver_attempts (
    order_id INT,
    driver_id INT,
    attempted_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (order_id, driver_id)
);
