CREATE TABLE IF NOT EXISTS public.user (
  id        SERIAL PRIMARY KEY,
  passport  VARCHAR(32) NOT NULL UNIQUE,
  password  VARCHAR(64) NOT NULL,
  nickname  VARCHAR(64),
  status    SMALLINT DEFAULT 1,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 可选：自动更新 updated_at
CREATE OR REPLACE FUNCTION set_updated_at()
RETURNS TRIGGER AS $$
BEGIN
  NEW.updated_at = CURRENT_TIMESTAMP;
  RETURN NEW;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER trg_user_updated
BEFORE UPDATE ON public.user
FOR EACH ROW
EXECUTE FUNCTION set_updated_at();