FoxxMD / context-mod

an event-based, reddit moderation bot built on top of snoowrap and written in typescript
https://contextmod.dev
MIT License
49 stars 11 forks source link

Primary identifier for Check and Run db entities are not unique to manager #135

Open FoxxMD opened 1 year ago

FoxxMD commented 1 year ago

Check and Run entities are using their name as the primary key. Even though they have a manager id relationship it is not used as part of a composite key.

This was for sure by accident and not intentional...for postgres, at least, this doesn't seem to cause immediate issues but for mysql/maria if a user tries to run CM with multiple subreddits using the same run/check names in each subreddit config CM will encounter db insert errors due to non-unique primary keys.

Solution is to use composite key or random id primary key. In either solution we will need to manually update result entities to match new key or truncate result tables during migration.