feat(auth): add lastSeenAt field to user schema and tests

This commit is contained in:
RainbowBird
2026-08-17 21:57:25 +08:00
parent bd790098d2
commit 5ea7bb1083
5 changed files with 52 additions and 8 deletions
@@ -13,14 +13,6 @@ export const user = pgTable('user', {
banned: boolean('banned').default(false),
banReason: text('ban_reason'),
banExpires: timestamp('ban_expires'),
// NOTICE:
// Touched in `databaseHooks.session.create.after` (see auth.ts) which
// fires on sign-in AND on every OIDC access-token refresh (~hourly), so
// this is effectively "last activity" for any user with a live client.
// Better Auth has `session.updatedAt` but that's per-session-row; we
// want one stable per-user timestamp for DAU-style queries without
// joining/aggregating session rows. Nullable so existing rows backfill
// lazily on next login instead of needing a migration-time seed.
lastSeenAt: timestamp('last_seen_at'),
createdAt: timestamp('created_at').defaultNow().notNull(),
updatedAt: timestamp('updated_at')