alter table user_invitations add column if not exists token_hash text, add column if not exists accepted_by_user_id uuid references users(id); create unique index if not exists idx_user_invitations_token_hash on user_invitations (token_hash) where token_hash is not null; create table if not exists password_reset_tokens ( id uuid primary key, user_id uuid not null references users(id) on delete cascade, token_hash text not null unique, expires_at timestamptz not null, used_at timestamptz, created_at timestamptz not null default now() ); create index if not exists idx_password_reset_tokens_user on password_reset_tokens (user_id, expires_at); alter table email_outbox add column if not exists subject text, add column if not exists delivered_via text;