entity: User
version: "1.0"
description: "User account entity with authentication and role management"

fields:
  id:
    type: uuid
    primary: true
    generated: true
    description: "Unique user identifier"
    
  username:
    type: string
    required: true
    unique: true
    min_length: 3
    max_length: 50
    pattern: "^[a-zA-Z0-9_-]+$"
    description: "Unique username for login"
    
  email:
    type: email
    required: true
    unique: true
    max_length: 255
    description: "User email address"
    
  role:
    type: enum
    required: true
    values: [user, admin, god, supergod]
    default: user
    description: "User role defining access level"
    
  created_at:
    type: datetime
    generated: true
    immutable: true
    description: "Account creation timestamp"
    
  updated_at:
    type: datetime
    auto_update: true
    description: "Last update timestamp"

indexes:
  - fields: [username]
    unique: true
  - fields: [email]
    unique: true
  - fields: [role]

acl:
  create:
    public: true
  read:
    self: true
    admin: true
  update:
    self: true
    admin: true
  delete:
    admin: true
