ALTER TABLE jam_tracks ADD COLUMN server_fixation_date DATE DEFAULT NOW();
ALTER TABLE jam_tracks ADD COLUMN hfa_license_status BOOLEAN DEFAULT FALSE;
ALTER TABLE jam_tracks ADD COLUMN hfa_license_desired BOOLEAN DEFAULT TRUE;
ALTER TABLE jam_tracks ADD COLUMN alternative_license_status BOOLEAN DEFAULT FALSE;
ALTER TABLE jam_tracks ADD COLUMN hfa_license_number INTEGER;
ALTER TABLE jam_tracks ADD COLUMN hfa_song_code VARCHAR;
ALTER TABLE jam_tracks ADD COLUMN album_title VARCHAR;

CREATE TABLE jam_track_hfa_requests (
  id SERIAL PRIMARY KEY,
  name VARCHAR NOT NULL,
  request_csv_filename VARCHAR,
  response_csv_filename VARCHAR,
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  approved_at TIMESTAMP,
  received_at TIMESTAMP
);

CREATE TABLE jam_track_hfa_request_ids (
  id VARCHAR(64) PRIMARY KEY DEFAULT uuid_generate_v4(),
  jam_track_id VARCHAR(64) NOT NULL REFERENCES jam_tracks(id) ON DELETE SET NULL,
  jam_track_hfa_request_id INTEGER REFERENCES jam_track_hfa_requests(id) ON DELETE SET NULL,
  request_id INTEGER,
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);