♻️ refactor: rewrite OAuth provision business logic for new user schema

This commit is contained in:
2026-05-28 21:29:20 +07:00
parent 57d19d4302
commit 96b5101742
10 changed files with 69 additions and 23 deletions

View File

@ -88,6 +88,7 @@ Table user_sessions {
browser_name String
browser_version String
ip_login String
valid_until DateTime [not null]
login_at DateTime [default: `now()`, not null]
logout_at DateTime
user_id String [not null]

View File

@ -0,0 +1,12 @@
-- DropForeignKey
ALTER TABLE "user_preferences" DROP CONSTRAINT "user_preferences_char_as_partner_id_fkey";
-- AlterTable
ALTER TABLE "user_oauth_accounts" ALTER COLUMN "provider_token" SET DATA TYPE TEXT,
ALTER COLUMN "refresh_token" SET DATA TYPE TEXT;
-- AlterTable
ALTER TABLE "user_preferences" ALTER COLUMN "char_as_partner_id" DROP NOT NULL;
-- AddForeignKey
ALTER TABLE "user_preferences" ADD CONSTRAINT "user_preferences_char_as_partner_id_fkey" FOREIGN KEY ("char_as_partner_id") REFERENCES "characters"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View File

@ -0,0 +1,8 @@
/*
Warnings:
- Added the required column `valid_until` to the `user_sessions` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "user_sessions" ADD COLUMN "valid_until" TIMESTAMPTZ NOT NULL;

View File

@ -175,8 +175,8 @@ model UserOauthAccounts {
provider_name auth_provider
provider_sub String? @db.VarChar(255)
provider_email String? @db.VarChar(255)
provider_token String? @db.VarChar(255)
refresh_token String? @db.VarChar(255)
provider_token String? @db.Text
refresh_token String? @db.Text
expires_at DateTime? @db.Timestamptz()
created_at DateTime @default(now()) @db.Timestamptz()
updated_at DateTime @updatedAt @db.Timestamptz()
@ -194,7 +194,8 @@ model UserSession {
browser_name String? @db.VarChar(50)
browser_version String? @db.VarChar(50)
ip_login String? @db.Inet()
login_at DateTime @default(now()) @db.Timestamptz()
valid_until DateTime @db.Timestamptz()
login_at DateTime @default(now()) @db.Timestamptz()
logout_at DateTime? @db.Timestamptz()
user_id String @db.Uuid