feat: adds support for last logged in auth method field

This commit is contained in:
=
2025-08-06 11:57:43 +05:30
parent 59cffe8cfb
commit 4dcd3ed06c
28 changed files with 366 additions and 134 deletions
@@ -0,0 +1,41 @@
import { Knex } from "knex";
import { TableName } from "../schemas";
export async function up(knex: Knex): Promise<void> {
const lastUserLoggedInAuthMethod = await knex.schema.hasColumn(TableName.OrgMembership, "lastLoggedInAuthMethod");
const lastIdentityLoggedInAuthMethod = await knex.schema.hasColumn(
TableName.IdentityOrgMembership,
"lastLoggedInAuthMethod"
);
if (!lastUserLoggedInAuthMethod) {
await knex.schema.alterTable(TableName.OrgMembership, (t) => {
t.string("lastLoggedInAuthMethod").nullable();
});
}
if (!lastIdentityLoggedInAuthMethod) {
await knex.schema.alterTable(TableName.IdentityOrgMembership, (t) => {
t.string("lastLoggedInAuthMethod").nullable();
});
}
}
export async function down(knex: Knex): Promise<void> {
const lastUserLoggedInAuthMethod = await knex.schema.hasColumn(TableName.OrgMembership, "lastLoggedInAuthMethod");
const lastIdentityLoggedInAuthMethod = await knex.schema.hasColumn(
TableName.IdentityOrgMembership,
"lastLoggedInAuthMethod"
);
if (!lastUserLoggedInAuthMethod) {
await knex.schema.alterTable(TableName.OrgMembership, (t) => {
t.dropColumn("lastLoggedInAuthMethod");
});
}
if (!lastIdentityLoggedInAuthMethod) {
await knex.schema.alterTable(TableName.IdentityOrgMembership, (t) => {
t.dropColumn("lastLoggedInAuthMethod");
});
}
}
@@ -14,7 +14,8 @@ export const IdentityOrgMembershipsSchema = z.object({
orgId: z.string().uuid(),
createdAt: z.date(),
updatedAt: z.date(),
identityId: z.string().uuid()
identityId: z.string().uuid(),
lastLoggedInAuthMethod: z.string().nullable().optional()
});
export type TIdentityOrgMemberships = z.infer<typeof IdentityOrgMembershipsSchema>;
+2 -1
View File
@@ -19,7 +19,8 @@ export const OrgMembershipsSchema = z.object({
roleId: z.string().uuid().nullable().optional(),
projectFavorites: z.string().array().nullable().optional(),
isActive: z.boolean().default(true),
lastInvitedAt: z.date().nullable().optional()
lastInvitedAt: z.date().nullable().optional(),
lastLoggedInAuthMethod: z.string().nullable().optional()
});
export type TOrgMemberships = z.infer<typeof OrgMembershipsSchema>;