Migrating users from supabase to better-auth, without downtime
Hi, I am trying to migrate from supabase auth to better-auth. We have a lot of users, and would prefer to do it without any downtime. It is okay for users to be signed out, but when signing in again, all of the supabase auth related data should be migrated. User ids should also stay the same.
What would be the cleanest option to do so?
I was playing around with database hooks. In user before create, I trigger the migration. It fails, because better-auth is trying to create the user later. Is it possible, to handle user creation on my own, by returning some flag?
Other option would be to just modify the id in before create, and than in after create, i would migrate all the other data. But this also doesn't seem to work.
Would it be better to just use regular hook?
5 Replies
Hey just wanted to double check - have you read through our Supabase migration guide?
https://better-auth.com/docs/guides/supabase-migration-guide
Migrating from Supabase Auth to Better Auth | Better Auth
A step-by-step guide to transitioning from Supabase Auth to Better Auth.
I did, but it is assuming downtime. I want to do it without any downtime for our users.
https://github.com/better-auth/better-auth/pull/3048
I guess this would could work for us. Unless you think there is a better/cleaner way to handle it?
GitHub
feat(database-hooks): Allow passing
id in DB hook create by pin...It's the same to using a custom idGenerator, except configurable by the database hook which would in theory provide more data.
A use-case is to generate the id based on user info in the use...
Can you tell me how it needs downtime?
It does not, I could copy most upfront, and move new ones with triggers.
It would be much simpler to migrate active users automaticaly via some hook and backfill the rest incrementaly.
So I am asking if you see any good approach with current functionality.