-- track extra detail about if the source went up or down
CREATE UNLOGGED TABLE icecast_source_changes (
  id VARCHAR(64) PRIMARY KEY DEFAULT uuid_generate_v4(),
  source_direction BOOLEAN NOT NULL,
  change_type VARCHAR(64) NOT NULL,
  user_id VARCHAR(64),
  client_id VARCHAR(64),
  success BOOLEAN NOT NULL,
  reason VARCHAR,
  detail VARCHAR,
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  icecast_mount_id VARCHAR(64) NOT NULL REFERENCES icecast_mounts(id) ON DELETE CASCADE
);

-- track when the source_direction
ALTER TABLE icecast_mounts ADD COLUMN source_direction BOOLEAN NOT NULL DEFAULT FALSE;