···3636 `delete from repos
3737 where owner = ?
3838 and repo_did = ?
3939- and created_at is not null
4040- and created_at < (
4141- select max(created_at) from repos
4242- where owner = ? and repo_did = ? and created_at is not null
3939+ and (
4040+ (created_at is null and exists (
4141+ select 1 from repos r2
4242+ where r2.owner = repos.owner
4343+ and r2.repo_did = repos.repo_did
4444+ and r2.created_at is not null
4545+ and r2.rkey <> repos.rkey
4646+ ))
4747+ or (created_at is not null and created_at < (
4848+ select max(created_at) from repos
4949+ where owner = ? and repo_did = ? and created_at is not null
5050+ ))
4351 )`,
4452 owner.String(), repoDid.String(), owner.String(), repoDid.String(),
4553 )