CREATE TABLE IF NOT EXISTS users (
  id TEXT PRIMARY KEY,
  username TEXT NOT NULL UNIQUE,
  password_hash TEXT NOT NULL,
  token_version INTEGER NOT NULL DEFAULT 1,
  display_name TEXT NOT NULL,
  login_provider TEXT NOT NULL DEFAULT 'password',
  account_status TEXT NOT NULL DEFAULT 'active',
  phone_number TEXT,
  phone_verified_at TEXT,
  created_at TEXT NOT NULL,
  updated_at TEXT NOT NULL
);

CREATE UNIQUE INDEX IF NOT EXISTS users_phone_number_unique_idx
  ON users (phone_number);
