template-saas-backend-v2/src/modules/auth/entities/session.entity.ts
rckrdmrd dfe6a715f0 Initial commit - Backend de template-saas migrado desde monorepo
Migración desde workspace-v2/projects/template-saas/apps/backend
Este repositorio es parte del estándar multi-repo v2

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 08:07:11 -06:00

50 lines
1.1 KiB
TypeScript

import {
Entity,
Column,
PrimaryGeneratedColumn,
CreateDateColumn,
Index,
} from 'typeorm';
@Entity({ schema: 'auth', name: 'sessions' })
export class Session {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ type: 'uuid' })
@Index()
user_id: string;
@Column({ type: 'uuid' })
@Index()
tenant_id: string;
@Column({ type: 'varchar', length: 64 })
@Index({ unique: true })
session_token: string;
@Column({ type: 'varchar', length: 64, nullable: true })
refresh_token_hash: string | null;
@Column({ type: 'varchar', length: 45, nullable: true })
ip_address: string | null;
@Column({ type: 'text', nullable: true })
user_agent: string | null;
@Column({ type: 'varchar', length: 50, nullable: true })
device_type: string | null;
@Column({ type: 'timestamp with time zone' })
expires_at: Date;
@Column({ type: 'timestamp with time zone', nullable: true })
last_activity_at: Date | null;
@Column({ type: 'boolean', default: true })
is_active: boolean;
@CreateDateColumn({ type: 'timestamp with time zone' })
created_at: Date;
}