It’s the same database structure as Reddit—a database in a database anti-pattern. Quoting Wikipedia:
In the database world, developers are sometimes tempted to bypass the RDBMS, for example by storing everything in one big table with three columns labelled entity ID, key, and value. While this entity-attribute-value model allows the developer to break out from the structure imposed by an SQL database, it loses out on all the benefits, since all of the work that could be done efficiently by the RDBMS is forced onto the application instead. Queries become much more convoluted, the indexes and query optimizer can no longer work effectively, and data validity constraints are not enforced. Performance and maintainability can be extremely poor.
LW database is exactly like this. Look at the existing scripts and despair.
Yup, it’s pretty horrible. But on the face of it—I know that appearances can deceive—it seems like you could iterate (inefficiently, but it’s not like this is going to be done often) over all the votes with a given voter-ID as in the “slow” case of user_downvote_karma and call Vote.vote with dir=Noneas defined in vote.py for each. Something along these lines, though it probably consists entirely of bugs:
from r2.models import Account, Link, Vote
user = Account._by_name('Eugine\_Nier')
# list() to make sure enumeration is done before we start changing the votes
# (dunno if we actually need to do that)
votee_ids = list([v.c._thing2_id for v in Vote._query(Vote.c._thing1_id == user._id)])
# dir = None to remove a vote
# ip = None because ip isn't needed when not creating a new vote
for votee_id in votee_ids: Vote.vote(user, Link._byID(votee_id), None, None)
It’s the same database structure as Reddit—a database in a database anti-pattern. Quoting Wikipedia:
LW database is exactly like this. Look at the existing scripts and despair.
Yup, it’s pretty horrible. But on the face of it—I know that appearances can deceive—it seems like you could iterate (inefficiently, but it’s not like this is going to be done often) over all the votes with a given voter-ID as in the “slow” case of user_downvote_karma and call
Vote.vote
withdir=None
as defined in vote.py for each. Something along these lines, though it probably consists entirely of bugs: