alter table token
rename to old_token;

create table token (
	id text
		not null
		primary key,
	secret text
		not null
		unique,
	login text
		not null,
	issued_at text
		not null,
	last_used_at text
		not null,
	foreign key (login)
		references login (id)
);

insert into token
select
	'T' || lower(hex(randomblob(8))) as id,
	*
from old_token;

drop table old_token;

create index token_issued_at on token (issued_at);
