-- +goose Up
-- Align duty roster schema with takeover flow.
-- A takeover creates a fresh roster row, so base/date must be a lookup index,
-- not a unique constraint.

ALTER TABLE duty_rosters
  ADD COLUMN flight_id BINARY(16) NULL AFTER id;

CREATE UNIQUE INDEX idx_roster_flight_id
  ON duty_rosters (flight_id);

DROP INDEX idx_roster_base_date ON duty_rosters;

CREATE INDEX idx_roster_base_date
  ON duty_rosters (base_id, duty_date);

-- +goose Down
DROP INDEX idx_roster_base_date ON duty_rosters;

CREATE UNIQUE INDEX idx_roster_base_date
  ON duty_rosters (base_id, duty_date);

DROP INDEX idx_roster_flight_id ON duty_rosters;

ALTER TABLE duty_rosters
  DROP COLUMN flight_id;
