When getting tables to truncate, panic on unknown version#1198
When getting tables to truncate, panic on unknown version#1198
Conversation
This one's related to code review feedback here [1]. When getting a list of tables that need to be truncated for the `TestSchema` helpers, it was possible to receive migration versions that didn't exist and the function would tolerate it, returning the latest known list of tables. This often works, but even where it does there's some risk of a new table coming in that doesn't end up getting cleaned up properly. Here, panic when receiving an unknown version number so that the problem can be corrected immediately. The panic may seem undesirable, but these functions are only used in tests, so it should be fine. [1] riverqueue/riverpro#281 (comment)
I may have misread the code in question, but I thought it was not returning any pro tables when the version wasn't explicitly listed in the |
Yeah I think that's right. Somehow the pro and non-pro versions ended up being implemented differently. I've run into issues with this non-pro version as well wherein I'd add a table, it wouldn't truncate, and I'd be sitting there trying to figure out wtf is going on. LLMs probably do a good job of this nowadays, but it was vexing, and shows that this could be improved. I'm thinking let's just change both instances to panics, and since these are test-only it should be fine. Thanks! |
This one's related to code review feedback here [1]. When getting a list
of tables that need to be truncated for the
TestSchemahelpers, it waspossible to receive migration versions that didn't exist and the
function would tolerate it, returning the latest known list of tables.
This often works, but even where it does there's some risk of a new
table coming in that doesn't end up getting cleaned up properly.
Here, panic when receiving an unknown version number so that the problem
can be corrected immediately. The panic may seem undesirable, but these
functions are only used in tests, so it should be fine.
[1] https://github.com/riverqueue/riverpro/pull/281#discussion_r3040295326