CREATE TABLE IF NOT EXISTS rent_a_car (
    id INT AUTO_INCREMENT PRIMARY KEY,
    korisnik_id INT NOT NULL,
    korisnik_najma VARCHAR(255) NOT NULL,
    adresa VARCHAR(255) NOT NULL,
    vozio_preuzeo VARCHAR(255) NOT NULL,
    broj_licne_pasos VARCHAR(100) NOT NULL,
    broj_vozacke VARCHAR(100) NOT NULL,
    drugi_vozac VARCHAR(255),
    drugi_vozac_broj_licne VARCHAR(100),
    drugi_vozac_broj_vozacke VARCHAR(100),
    tip_marka_vozila VARCHAR(255),
    registarska_oznaka VARCHAR(50),
    pocetak_mesto VARCHAR(255),
    pocetak_datum DATE,
    pocetak_vreme TIME,
    zavrsetak_mesto VARCHAR(255),
    zavrsetak_datum DATE,
    zavrsetak_vreme TIME,
    produzetak_najma ENUM('da', 'ne') DEFAULT 'ne',
    broj_produzenih_dana INT DEFAULT 0,
    pocetna_kilometraza DECIMAL(10, 2),
    zavrsena_kilometraza DECIMAL(10, 2),
    predjena_kilometraza DECIMAL(10, 2),
    ukupan_period_najma INT,
    iznos_depozita DECIMAL(10, 2) DEFAULT 0,
    ukupno_za_naplati DECIMAL(10, 2) DEFAULT 0,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP,
    FOREIGN KEY (korisnik_id) REFERENCES users(id)
);

CREATE TABLE IF NOT EXISTS rent_a_car_dokumenti (
    id INT AUTO_INCREMENT PRIMARY KEY,
    rent_a_car_id INT NOT NULL,
    uploaded_by INT NOT NULL,
    naziv_fajla VARCHAR(255) NOT NULL,
    putanja VARCHAR(500) NOT NULL,
    velicina_fajla INT NOT NULL,
    mime_type VARCHAR(100) NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (rent_a_car_id) REFERENCES rent_a_car(id) ON DELETE CASCADE,
    FOREIGN KEY (uploaded_by) REFERENCES users(id)
);

