refactor: remove 2fa migration

This commit is contained in:
Mauricio Siu 2025-02-17 00:10:34 -06:00
parent 7abe060fcf
commit 8c28223343

View File

@ -26,7 +26,6 @@ WITH inserted_users AS (
"serversQuantity", "serversQuantity",
"expirationDate", "expirationDate",
"createdAt", "createdAt",
"two_factor_enabled",
"isRegistered" "isRegistered"
) )
SELECT SELECT
@ -53,30 +52,11 @@ WITH inserted_users AS (
a."serversQuantity", a."serversQuantity",
NOW() + INTERVAL '1 year', NOW() + INTERVAL '1 year',
NOW(), NOW(),
COALESCE(auth."is2FAEnabled", false),
true true
FROM admin a FROM admin a
JOIN auth ON auth.id = a."authId" JOIN auth ON auth.id = a."authId"
RETURNING * RETURNING *
), ),
inserted_two_factor_admin AS (
-- Insertar registros en two_factor para admins con 2FA habilitado
INSERT INTO two_factor (
id,
secret,
backup_codes,
user_id
)
SELECT
gen_random_uuid(),
auth.secret,
gen_random_uuid()::text,
a."adminId"
FROM admin a
JOIN auth ON auth.id = a."authId"
WHERE auth."is2FAEnabled" = true
RETURNING *
),
inserted_accounts AS ( inserted_accounts AS (
-- Insertar cuentas para los admins -- Insertar cuentas para los admins
INSERT INTO account ( INSERT INTO account (
@ -85,7 +65,6 @@ inserted_accounts AS (
"provider_id", "provider_id",
"user_id", "user_id",
password, password,
"is2FAEnabled",
"created_at", "created_at",
"updated_at" "updated_at"
) )
@ -95,7 +74,6 @@ inserted_accounts AS (
'credential', 'credential',
a."adminId", a."adminId",
auth.password, auth.password,
COALESCE(auth."is2FAEnabled", false),
NOW(), NOW(),
NOW() NOW()
FROM admin a FROM admin a
@ -143,7 +121,6 @@ inserted_members AS (
"accesedProjects", "accesedProjects",
"accesedServices", "accesedServices",
"expirationDate", "expirationDate",
"two_factor_enabled",
"isRegistered" "isRegistered"
) )
SELECT SELECT
@ -166,7 +143,6 @@ inserted_members AS (
COALESCE(u."accesedProjects", '{}'), COALESCE(u."accesedProjects", '{}'),
COALESCE(u."accesedServices", '{}'), COALESCE(u."accesedServices", '{}'),
NOW() + INTERVAL '1 year', NOW() + INTERVAL '1 year',
COALESCE(auth."is2FAEnabled", false),
COALESCE(u."isRegistered", false) COALESCE(u."isRegistered", false)
FROM "user" u FROM "user" u
JOIN admin a ON u."adminId" = a."adminId" JOIN admin a ON u."adminId" = a."adminId"
@ -181,7 +157,6 @@ inserted_member_accounts AS (
"provider_id", "provider_id",
"user_id", "user_id",
password, password,
"is2FAEnabled",
"created_at", "created_at",
"updated_at" "updated_at"
) )
@ -191,7 +166,6 @@ inserted_member_accounts AS (
'credential', 'credential',
u."userId", u."userId",
auth.password, auth.password,
COALESCE(auth."is2FAEnabled", false),
NOW(), NOW(),
NOW() NOW()
FROM "user" u FROM "user" u
@ -199,25 +173,6 @@ inserted_member_accounts AS (
JOIN auth ON auth.id = u."authId" JOIN auth ON auth.id = u."authId"
RETURNING * RETURNING *
), ),
inserted_two_factor_members AS (
-- Insertar registros en two_factor para miembros con 2FA habilitado
INSERT INTO two_factor (
id,
secret,
backup_codes,
user_id
)
SELECT
gen_random_uuid(),
auth.secret,
gen_random_uuid()::text,
u."userId"
FROM "user" u
JOIN admin a ON u."adminId" = a."adminId"
JOIN auth ON auth.id = u."authId"
WHERE auth."is2FAEnabled" = true
RETURNING *
),
inserted_admin_members AS ( inserted_admin_members AS (
-- Insertar miembros en las organizaciones (admins como owners) -- Insertar miembros en las organizaciones (admins como owners)
INSERT INTO member ( INSERT INTO member (