forked from unkeyed/unkey
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
589 additions
and
578 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
title: 0006 Auth Migration | ||
description: Migrate everything to WorkOS, despite their bad APIs.. | ||
date: 2024-12-18 | ||
authors: | ||
- Andreas Thomas | ||
- James Perkins | ||
--- | ||
|
||
|
||
## Motivation | ||
|
||
We need to migrate our users and organisations from Clerk to WorkOS. | ||
|
||
|
||
## Detailed design | ||
|
||
|
||
In order to apply the changes safely and, more importantly, roll back in case we need to, we'll need to do it in 3 steps. | ||
Each step should be its own PR, so we can roll back safely. | ||
|
||
|
||
### 1. Migrate Data | ||
|
||
1. Create a new non-nullable varchar column in our `workspaces` table with default `""`. | ||
2. Migrate all users from Clerk to WorkOS. They will receive a new `user_id`, which is fine. | ||
3. Migrate all organisations and personal workspaces from Clerk to WorkOS. These will also have a new `org_id`, which we will store in the `workspaces.organisation_id` column. | ||
|
||
### 2. Switch Reads | ||
(Meg's PR) | ||
|
||
We deploy the dashboard changes to production, which will now receive an `orgId` from the WorkOS SDK and change our db queries to match against the `organisation_id` field, instead of `tenant_id`. | ||
If we really need to, we can roll this back at any time and use clerk again. The only problem here is that users that were created after the switch, would not be in Clerk. | ||
|
||
|
||
### 3. Remove old columns | ||
|
||
After we're happy with everything and it's been running smoothly for a few weeks, we can remove the old `tenant_id` column. |
Oops, something went wrong.