diff --git a/apps/dokploy/drizzle/0067_migrate-data.sql b/apps/dokploy/drizzle/0067_migrate-data.sql index 62604d32c..b5cefd7b7 100644 --- a/apps/dokploy/drizzle/0067_migrate-data.sql +++ b/apps/dokploy/drizzle/0067_migrate-data.sql @@ -150,6 +150,32 @@ inserted_members AS ( JOIN admin a ON u."adminId" = a."adminId" JOIN auth ON auth.id = u."authId" 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 INSERT INTO member ( diff --git a/apps/dokploy/migrate.ts b/apps/dokploy/migrate.ts index bcbac2336..8a8e0dcbe 100644 --- a/apps/dokploy/migrate.ts +++ b/apps/dokploy/migrate.ts @@ -100,6 +100,15 @@ await db .returning() .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({ organizationId: organization?.id || "", userId: userTemp?.id || "",