CREATE TABLE music_sessions_history (
  id character varying(64) NOT NULL DEFAULT uuid_generate_v4(),
  music_session_id varchar(64) NOT NULL,
  description character varying(8000),
  user_id character varying(64) NOT NULL references users(id),
  band_id character varying(64) references bands(id) on delete cascade,
  genres VARCHAR(255),
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  session_removed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

ALTER TABLE music_sessions_history ADD CONSTRAINT music_session_uniqkey UNIQUE (music_session_id);

CREATE TABLE music_sessions_user_history (
  id character varying(64) NOT NULL DEFAULT uuid_generate_v4(),
  music_session_id varchar(64) NOT NULL references music_sessions_history(music_session_id),
  user_id character varying(64) NOT NULL references users(id),
  client_id character varying(64) NOT NULL,
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
