Migrating EPTSS Supabase instances
Moving the production instance off of my personal Supabase account
This is a work log of the migration. This is a follow up to this post in which I talk EPTSS UX hardening. This new EPTSS specific Supabase account will house both the prod and staging database.
After an application refactor (to allow zero records, for when the app is pointed to an empty db), I'm ready to go.
Steps -
- Run the application locally against the production database and manually test for regressions.
- Swap the environment variables in my Netlify deploy to the new vars
NEXT_PUBLIC_SUPABASE_ANON_KEY
- used for authNEXT_PUBLIC_SUPABASE_URL
- used for authDATABASE_URL
- used for CRUD db connection
- Confirm we're pointing at the new db (we can check this by confirming the /health page is blank)
- Perform regression testing on production
- Migrate 2 additional keys -
SUPABASE_SERVICE_ROLE_KEY
- for cypress testingNEXT_PUBLIC_SUPABASE_USER_CREATION_TOKEN
- for public schema user creation on auth user creation (I'm no longer using a DB trigger for this workflow)
- Confirm new user creation works
- Confirm cypress test works
Doing the work
I'm already discovering that the above steps are imperfect, but directionally correct!
confirming the new db connection
I've successfully made it step 3, confirming we're talking to the new DB.
But this page doesn't look as expected. Why is there 1 successful run? I mean, I understand that GH action runs on a cron job, but it should have failed?
It turns out, it did fail! And the test has been failing for a while now. It just does not correctly report "FAILURE" on failure. It fails and then reports 👍.
So, TODO: fix cypress test.
But for now, we're live on the new site.
Logging into the site via Magic Link
first, I had to add the production domain to the site url config in Supabase.
The initial test took me to https://everyoneplaysthesamesong.com/https:/everyoneplaysthesamesong.com?token_hash={HASHTOKEN}&type=magiclink&next=https%3A%2F%2Feveryoneplaysthesamesong.com
which is clearly wrong. My root domain is duplicated. The link from the email itself looks good, so the issue must be in my callback logic.
this commit fixed the problem.
New user creation test
and boom, my new user is shown in the dashboard!
Wiring up Resend
For now I'll use my same Resend account for sending Magic Link emails.
I login to my Supabase account through Resend and setup up the integration.
and just like that, we're set up!
And we're migrated!!
There are a few workflows that don't appear to working, but those won't be necessary for another month or so, based on the timeline of the project.