create table if not exists user_token
(
    id         bigserial
        primary key,
    "user"     uuid                     not null,
    name       varchar(255)             not null,
    token_hash varchar(255)             not null,
    scopes     jsonb                    not null,
    expires_at timestamp with time zone,
    is_revoked boolean default false    not null,
    created_at timestamp with time zone not null,
    updated_at timestamp with time zone not null
);

create index if not exists idx_user_token_user
    on user_token ("user");
