CREATE TABLE IF NOT EXISTS spbu (
  id INT AUTO_INCREMENT PRIMARY KEY,
  nama VARCHAR(150) NOT NULL,
  hp VARCHAR(50) DEFAULT NULL,
  buka TINYINT(1) NOT NULL DEFAULT 1,
  lat DECIMAL(12,8) NOT NULL,
  lng DECIMAL(12,8) NOT NULL,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS jalan (
  id INT AUTO_INCREMENT PRIMARY KEY,
  status VARCHAR(100) NOT NULL,
  panjang DECIMAL(12,2) DEFAULT 0,
  koordinat LONGTEXT NOT NULL,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS tanah (
  id INT AUTO_INCREMENT PRIMARY KEY,
  status VARCHAR(100) NOT NULL,
  luas DECIMAL(12,2) DEFAULT 0,
  koordinat LONGTEXT NOT NULL,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS populasi_kecamatan (
  id INT AUTO_INCREMENT PRIMARY KEY,
  kecamatan VARCHAR(100) NOT NULL UNIQUE,
  populasi INT NOT NULL DEFAULT 0,
  updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

INSERT INTO spbu (nama, hp, buka, lat, lng) VALUES
('SPBU Ahmad Yani', '081234567890', 1, -0.05586000, 109.34725000),
('SPBU Imam Bonjol', '081234567891', 0, -0.03372000, 109.34201000),
('SPBU Sungai Raya Dalam', '081234567892', 1, -0.07043000, 109.37850000)
ON DUPLICATE KEY UPDATE nama=VALUES(nama);

INSERT INTO populasi_kecamatan (kecamatan, populasi) VALUES
('Pontianak Barat', 150000),
('Pontianak Kota', 130000),
('Pontianak Selatan', 95000),
('Pontianak Tenggara', 53000),
('Pontianak Timur', 104000),
('Pontianak Utara', 128000)
ON DUPLICATE KEY UPDATE populasi=VALUES(populasi);
