mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: update migration
This commit is contained in:
@@ -150,6 +150,32 @@ inserted_members AS (
|
|||||||
JOIN admin a ON u."adminId" = a."adminId"
|
JOIN admin a ON u."adminId" = a."adminId"
|
||||||
JOIN auth ON auth.id = u."authId"
|
JOIN auth ON auth.id = u."authId"
|
||||||
RETURNING *
|
RETURNING *
|
||||||
|
),
|
||||||
|
inserted_member_accounts AS (
|
||||||
|
-- Insertar cuentas para los usuarios miembros
|
||||||
|
INSERT INTO account (
|
||||||
|
id,
|
||||||
|
"account_id",
|
||||||
|
"provider_id",
|
||||||
|
"user_id",
|
||||||
|
password,
|
||||||
|
"is2FAEnabled",
|
||||||
|
"created_at",
|
||||||
|
"updated_at"
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
gen_random_uuid(),
|
||||||
|
gen_random_uuid(),
|
||||||
|
'credentials',
|
||||||
|
u."userId",
|
||||||
|
auth.password,
|
||||||
|
COALESCE(auth."is2FAEnabled", false),
|
||||||
|
NOW(),
|
||||||
|
NOW()
|
||||||
|
FROM "user" u
|
||||||
|
JOIN admin a ON u."adminId" = a."adminId"
|
||||||
|
JOIN auth ON auth.id = u."authId"
|
||||||
|
RETURNING *
|
||||||
)
|
)
|
||||||
-- Insertar miembros en las organizaciones
|
-- Insertar miembros en las organizaciones
|
||||||
INSERT INTO member (
|
INSERT INTO member (
|
||||||
|
|||||||
@@ -100,6 +100,15 @@ await db
|
|||||||
.returning()
|
.returning()
|
||||||
.then((userTemp) => userTemp[0]);
|
.then((userTemp) => userTemp[0]);
|
||||||
|
|
||||||
|
await db.insert(schema.account).values({
|
||||||
|
providerId: "credentials",
|
||||||
|
userId: member?.userId || "",
|
||||||
|
password: member.auth.password,
|
||||||
|
is2FAEnabled: member.auth.is2FAEnabled || false,
|
||||||
|
createdAt: new Date(member.auth.createdAt) || new Date(),
|
||||||
|
updatedAt: new Date(member.auth.createdAt) || new Date(),
|
||||||
|
});
|
||||||
|
|
||||||
await db.insert(schema.member).values({
|
await db.insert(schema.member).values({
|
||||||
organizationId: organization?.id || "",
|
organizationId: organization?.id || "",
|
||||||
userId: userTemp?.id || "",
|
userId: userTemp?.id || "",
|
||||||
|
|||||||
Reference in New Issue
Block a user