mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-04 21:04:37 +08:00
Fix OAuth provider migration (#793)
<!--
Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md
-->
<!-- ELLIPSIS_HIDDEN -->
----
> [!IMPORTANT]
> Fixes OAuth provider migration by updating schema, constraints, and
foreign keys in `ProjectUserOAuthAccount`, `OAuthAccessToken`, and
`OAuthToken`.
>
> - **Schema Changes**:
> - `ProjectUserOAuthAccount`: Add `allowConnectedAccounts` and
`allowSignIn` columns with default `true`. Add `id` column, generate
UUIDs for existing rows, set `id` as NOT NULL and primary key.
> - `OAuthAccessToken` and `OAuthToken`: Add `oauthAccountId` column,
update with `ProjectUserOAuthAccount.id`, drop `configOAuthProviderId`
and `providerAccountId` columns, set `oauthAccountId` as NOT NULL.
> - **Constraints and Indexes**:
> - Add unique index on `OAuthAuthMethod` for `tenancyId`,
`projectUserId`, `configOAuthProviderId`.
> - Add foreign keys linking `OAuthAuthMethod`, `OAuthToken`, and
`OAuthAccessToken` to `ProjectUserOAuthAccount`.
> - Drop `ConnectedAccount` table.
> - **Misc**:
> - `ProjectUserOAuthAccount`: Allow `projectUserId` to be NULL.
>
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=stack-auth%2Fstack-auth&utm_source=github&utm_medium=referral)<sup>
for a27230eb54. You can
[customize](https://app.ellipsis.dev/stack-auth/settings/summaries) this
summary. It will automatically update as commits are pushed.</sup>
<!-- ELLIPSIS_HIDDEN -->
This commit is contained in:
parent
6a58bb03b0
commit
aacbdf4dd6
@ -26,7 +26,13 @@ ALTER TABLE "OAuthToken" DROP CONSTRAINT "OAuthToken_tenancyId_configOAuthProvid
|
||||
ALTER TABLE "ProjectUserOAuthAccount" DROP CONSTRAINT "ProjectUserOAuthAccount_pkey",
|
||||
ADD COLUMN "allowConnectedAccounts" BOOLEAN NOT NULL DEFAULT true,
|
||||
ADD COLUMN "allowSignIn" BOOLEAN NOT NULL DEFAULT true,
|
||||
ADD COLUMN "id" UUID NOT NULL,
|
||||
ADD COLUMN "id" UUID;
|
||||
|
||||
-- Generate UUIDs for existing rows
|
||||
UPDATE "ProjectUserOAuthAccount" SET "id" = gen_random_uuid() WHERE "id" IS NULL;
|
||||
|
||||
-- Make id column NOT NULL and set as primary key
|
||||
ALTER TABLE "ProjectUserOAuthAccount" ALTER COLUMN "id" SET NOT NULL,
|
||||
ADD CONSTRAINT "ProjectUserOAuthAccount_pkey" PRIMARY KEY ("tenancyId", "id");
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user