Skip to content

users

Overview

System users. There is no explicit registration step; a user is created automatically the first time an authenticated request arrives.

Table Definition

Logical name Physical name Column Type PK Relation Unique Nullable Default Notes
User users id uuid โ—ฏ gen_random_uuid()
name varchar(255) Display name, updated from the auth headers
email varchar(255) โ—ฏ Stored normalized to lower case
is_admin boolean false Derived automatically from SURVEY_ADMIN_EMAILS
created_at timestamptz now()
updated_at timestamptz now()

Relations

  • Referenced by: surveys.created_by / surveys.updated_by (restrict)
  • Referenced by: survey_permissions.user_id (cascade)
  • Referenced by: survey_versions.created_by (restrict)
  • Referenced by: user_survey_favorites.user_id (cascade)
  • Referenced by: question_library_items.created_by (set null)
  • Referenced by: external_surveys.imported_by (set null)

Indexes

  • Primary key (id)
  • UNIQUE: email

Notes

  • is_admin is compared against SURVEY_ADMIN_EMAILS on every request and updated if it changed. Editing the database directly has no lasting effect; the environment variable is authoritative
  • Administrators can view and edit every survey regardless of permission records
  • Calling the import API with API key authentication and no x-user-email creates import-bot@local (display name Import Bot) automatically
  • Soft deletion is not supported