entity: Session
version: "1.0"
description: "User session tracking and management"

fields:
  id:
    type: uuid
    primary: true
    generated: true
    
  user_id:
    type: uuid
    required: true
    foreign_key:
      entity: User
      field: id
      on_delete: cascade
      
  token:
    type: string
    required: true
    unique: true
    sensitive: true
    description: "Session token"
    
  expires_at:
    type: datetime
    required: true
    description: "Session expiration time"
    
  created_at:
    type: datetime
    generated: true
    immutable: true
    
  last_activity:
    type: datetime
    auto_update: true

indexes:
  - fields: [token]
    unique: true
  - fields: [user_id]
  - fields: [expires_at]

ttl:
  field: expires_at
  auto_delete: true

acl:
  create:
    system: true
  read:
    system: true
  update:
    system: true
  delete:
    system: true
