In literal terms, if a certain issue is "on the ballot," it means that when a voter fills out a ballot (i.e., a paper form or computer screen on which a person's vote is recorded), the voter has to mark his/her opinion regarding that issue as part of the process of voting. For example, if the legal drinking age is "on the ballot," it would mean that there is a question on the ballot form that involves the legal drinking age (perhaps asking whether the legal age should changed from its current level).
In your example of "When our very democracy was on the ballot," this phrase is being used figuratively. The ballot form did NOT include a question about whether we should keep our democracy or not (which would be a literal interpretation). Most likely, the writer is suggesting that a vote for one candidate would have resulted in serious threats to our system of democracy based on what we know about that candidate's goals and values, while a vote for an opposing candidate would have resulted in maintaining our system of democracy based on that candidate's goals and values. So, in effect, filling in the oval on the ballot next to one candidate's name would have implied that the voter has a lack of concern for democratic processes or ideals which that candidate has a record of undermining or subverting. In this way, the possibility that the candidate perceived as anti-democracy could have won (but did not) meant that our system of democracy was, indirectly, up for a vote, or "on the ballot."