

CREATE TABLE IF NOT EXISTS return_items (
  id INT UNSIGNED NOT NULL AUTO_INCREMENT,
  return_id INT UNSIGNED NOT NULL,
  product_name VARCHAR(255) NOT NULL,
  sku VARCHAR(128) NULL,
  quantity INT NOT NULL DEFAULT 1,
  reason VARCHAR(255) NULL,
  condition_note VARCHAR(255) NULL,
  serial_number VARCHAR(255) NULL,
  PRIMARY KEY (id),
  KEY idx_return_id (return_id),
  CONSTRAINT fk_return_items_return FOREIGN KEY (return_id) REFERENCES returns(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;



-- Cache geolocație Sameday (județe/localități) pentru a nu depinde constant de API
CREATE TABLE IF NOT EXISTS sameday_geo_counties (
  id INT NOT NULL PRIMARY KEY,
  name VARCHAR(128) NOT NULL,
  code VARCHAR(16) NULL,
  updated_at DATETIME NOT NULL,
  KEY idx_name (name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS sameday_geo_cities (
  id INT NOT NULL PRIMARY KEY,
  county_id INT NOT NULL,
  name VARCHAR(128) NOT NULL,
  extra_km DECIMAL(8,2) NULL,
  updated_at DATETIME NOT NULL,
  KEY idx_county (county_id),
  KEY idx_name (name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- (Optional) Cache lockere; util dacă pe viitor vrei listare locală
CREATE TABLE IF NOT EXISTS sameday_lockers (
  id INT NOT NULL PRIMARY KEY,
  name VARCHAR(255) NOT NULL,
  address VARCHAR(255) NULL,
  city VARCHAR(128) NULL,
  county VARCHAR(128) NULL,
  lat DECIMAL(10,7) NULL,
  lng DECIMAL(10,7) NULL,
  updated_at DATETIME NOT NULL,
  KEY idx_city (city),
  KEY idx_county (county)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
