Why does Ecto report a StaleEntryError for cast_assoc in Changeset?

My migration to add schedule to element is this:

    alter table(:elements) do
      add(:schedule_id, references(:schedules, type: :uuid, on_delete: :delete_all))
    end

My thought was if the element is deleted, it should also delete any related schedules (schedules aren’t shared across multiple items).