-- Run this once in phpMyAdmin (SQL tab) against the MySQL database you create
-- for cycletracker.11seas.com via cPanel → MySQL Databases.

CREATE TABLE IF NOT EXISTS users (
  id INT AUTO_INCREMENT PRIMARY KEY,
  user_name VARCHAR(255) NOT NULL,
  email VARCHAR(255) NOT NULL UNIQUE,
  password_hash VARCHAR(255) NOT NULL,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE IF NOT EXISTS bike_ride_details (
  id INT AUTO_INCREMENT PRIMARY KEY,
  user_id INT NOT NULL,
  mrv_id VARCHAR(100),
  start_time DATETIME,
  end_time DATETIME,
  distance DECIMAL(10,4),
  duration INT,
  average_speed DECIMAL(10,2),
  activity_type VARCHAR(50),
  start_lat DECIMAL(10,7) NULL,
  start_lng DECIMAL(10,7) NULL,
  start_address VARCHAR(500) NULL,
  end_lat DECIMAL(10,7) NULL,
  end_lng DECIMAL(10,7) NULL,
  end_address VARCHAR(500) NULL,
  is_last_ride TINYINT(1) DEFAULT 0,
  odo_reading INT NULL,
  route_image VARCHAR(500) NULL,
  odo_photo VARCHAR(500) NULL,
  route_points LONGTEXT NULL,
  elevation_gain DECIMAL(10,2) DEFAULT 0,
  verification_photos LONGTEXT NULL,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
