Signed-off-by: Seongmin Lee git@boltless.me
+26
Diff
round #1
+26
knotmirror/db/db.go
+26
knotmirror/db/db.go
···
50
50
error_msg text,
51
51
retry_count integer not null default 0,
52
52
retry_after integer not null default 0,
53
+
db_created_at timestamptz not null default now(),
54
+
db_updated_at timestamptz not null default now(),
53
55
54
56
constraint repos_pkey primary key (did, rkey)
55
57
);
···
60
62
no_ssl boolean not null default false,
61
63
status text not null default 'active',
62
64
last_seq bigint not null default -1,
65
+
db_created_at timestamptz not null default now(),
66
+
db_updated_at timestamptz not null default now(),
63
67
64
68
constraint hosts_pkey primary key (hostname)
65
69
);
66
70
67
71
create index if not exists idx_repos_aturi on repos (at_uri);
72
+
create index if not exists idx_repos_db_updated_at on repos (db_updated_at desc);
73
+
create index if not exists idx_hosts_db_updated_at on hosts (db_updated_at desc);
74
+
75
+
create or replace function set_updated_at()
76
+
returns trigger as $$
77
+
begin
78
+
new.db_updated_at = now();
79
+
return new;
80
+
end;
81
+
$$ language plpgsql;
82
+
83
+
drop trigger if exists repos_set_updated_at on repos;
84
+
create trigger repos_set_updated_at
85
+
before update on repos
86
+
for each row
87
+
execute function set_updated_at();
88
+
89
+
drop trigger if exists hosts_set_updated_at on hosts;
90
+
create trigger hosts_set_updated_at
91
+
before update on hosts
92
+
for each row
93
+
execute function set_updated_at();
68
94
`)
69
95
if err != nil {
70
96
return nil, fmt.Errorf("initializing db schema: %w", err)
History
2 rounds
1 comment
boltless.me
submitted
#1
1 commit
expand
collapse
knotmirror/db: add timestamps to track syncs
Signed-off-by: Seongmin Lee <git@boltless.me>
expand 1 comment
This pull has been deleted (possibly by jj abandon or jj squash)
boltless.me
submitted
#0
1 commit
expand
collapse
knotmirror/db: add timestamps to track syncs
Signed-off-by: Seongmin Lee <git@boltless.me>
lgtm