The only topic I could find with a similar problem was Unable to login into discourse suddenly - #8 by Tarek_Khalil, and the advice was to restore a backup from before the migration snafu, which may not be the best option in your case as it was some time ago.
I’m afraid database errors are out of my skillset. @pfaffman and @RGJ are normally very good at these (though I don’t know if this is something they’ve come across before). Do you guys have any tricks up your sleeve for this?