···5050 error_msg text,
5151 retry_count integer not null default 0,
5252 retry_after integer not null default 0,
5353+ db_created_at timestamptz not null default now(),
5454+ db_updated_at timestamptz not null default now(),
53555456 constraint repos_pkey primary key (did, rkey)
5557 );
···6062 no_ssl boolean not null default false,
6163 status text not null default 'active',
6264 last_seq bigint not null default -1,
6565+ db_created_at timestamptz not null default now(),
6666+ db_updated_at timestamptz not null default now(),
63676468 constraint hosts_pkey primary key (hostname)
6569 );
66706771 create index if not exists idx_repos_aturi on repos (at_uri);
7272+ create index if not exists idx_repos_db_updated_at on repos (db_updated_at desc);
7373+ create index if not exists idx_hosts_db_updated_at on hosts (db_updated_at desc);
7474+7575+ create or replace function set_updated_at()
7676+ returns trigger as $$
7777+ begin
7878+ new.db_updated_at = now();
7979+ return new;
8080+ end;
8181+ $$ language plpgsql;
8282+8383+ drop trigger if exists repos_set_updated_at on repos;
8484+ create trigger repos_set_updated_at
8585+ before update on repos
8686+ for each row
8787+ execute function set_updated_at();
8888+8989+ drop trigger if exists hosts_set_updated_at on hosts;
9090+ create trigger hosts_set_updated_at
9191+ before update on hosts
9292+ for each row
9393+ execute function set_updated_at();
6894 `)
6995 if err != nil {
7096 return nil, fmt.Errorf("initializing db schema: %w", err)