-- Database untuk project 01/04: GIS SPBU
CREATE DATABASE IF NOT EXISTS gis_spbu
  CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

USE gis_spbu;

CREATE TABLE IF NOT EXISTS spbu (
    id INT AUTO_INCREMENT PRIMARY KEY,
    nama_spbu VARCHAR(150) NOT NULL,
    no_wa VARCHAR(30) NOT NULL,
    status ENUM('yes','no') NOT NULL DEFAULT 'no',
    latitude DECIMAL(10,8) NOT NULL,
    longitude DECIMAL(11,8) NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

ALTER TABLE spbu
    MODIFY status ENUM('yes','no') NOT NULL DEFAULT 'no';

-- Insert Dummy Data for Testing
INSERT INTO spbu (nama_spbu, no_wa, status, latitude, longitude) VALUES
('SPBU Ahmad Yani', '081234567890', 'yes', -0.026300, 109.342500),
('SPBU Tanjungpura', '089876543210', 'no', -0.018500, 109.331500),
('SPBU Sungai Jawi', '085211223344', 'yes', -0.011200, 109.320500);
