Rollback failed, how do I restore?

Deployed a working version, had agent make some app changes in dev, after I created RLS policies and enabled RLS in databases. Agent progressively broke more and more, so I rolled back, including database rollback. Rollback carried back the bugs, my dev environment is very broken.

  • Dev database rollback seems complete. RLS is disabled and policies are dropped. New tables are gone.
  • Deployment database rollback rolled back only one table (sessions), as far as I can tell. It kept new the new policies, new roles, new tables
  • Edited DATABASE_URL secret (least-privileged app_user) was not rolled back (but I can do that manually easily)
  • New DATABASE_URL_AUTH secret agent had me create was kept
  • Deployment environment is [EDIT] partially fine. App users have 70% functionality intact. Registration flow has a new bug it didn’t have before the dev changes. Superadmin dashboard is cooked.
  • Deployed app is somehow writing to db even though DATABASE_URL secret is different now (perhaps because DATABASE_URL in sql admin>settings>environmental variables doesn’t change when you edit the DATABASE_URL secret?)
  • Deployed app is somehow writing to new db tables that didn’t exist when it was deployed.

I have auto git commit on, so I have the commits. But the commits from the last stable dev version weren’t pushed to remote yet, or anything after that.

What’s the best way to get back to the stable version? Before the rollback, agent destroyed so many files, I don’t know 1) what all was broken and 2) which broken pieces were brought “back from the future”. File History carried changes back in time, too. I’m capable of disabling dep db RLS and dropping the RLS policies on my own if necessary using sql console. The rest, I could really use some help. Thanks to anyone willing to help.

Update: I have disabled RLS on all tables in the deployment database (policies and some additional GRANTs and REVOKES left in place) and that cleared up most of the new issues in deployment environment.

Dev is still cooked, of course.