feat: archive only parents

This commit is contained in:
Yanislav Igonin 2021-11-20 22:42:16 +02:00
parent 8c448d11a1
commit 21f804cafb
2 changed files with 7 additions and 5 deletions

View File

@ -2,6 +2,7 @@
Go tryout. Single board imageboard.
## Prerequisites
Create db.
Run migrations from `migrations`.
Create `.env` file from `.env.example`, change env vars to your needs.
1. Go 1.13+.
2. PostgreSQL.
3. Create `.env` file from `.env.example`, change env vars to your needs.
4. Create db with the name that is specified in `.env` file in `POSTGRES_URL` env var.

View File

@ -236,8 +236,9 @@ func (r *PostsRepository) ArchiveThreadsFrom(t time.Time) error {
sql := `
UPDATE posts
SET is_archived = true
WHERE
is_archived != true
WHERE
is_parent = true
AND is_archived != true
AND updated_at <= $1
`