Rename the unified post date field.
CI / test (pull_request) Successful in 6m16s

Use post_date throughout the new schema while retaining hunt_date only as the legacy migration source.
This commit is contained in:
2026-08-27 00:03:10 -07:00
parent 007fcd0991
commit c6b5d6a456
4 changed files with 18 additions and 18 deletions
+7 -7
View File
@@ -50,22 +50,22 @@ CREATE TABLE IF NOT EXISTS posts (
title TEXT NOT NULL DEFAULT '',
body TEXT NOT NULL,
city TEXT NOT NULL DEFAULT '',
hunt_date TEXT NOT NULL DEFAULT '',
post_date TEXT NOT NULL DEFAULT '',
hidden INTEGER NOT NULL DEFAULT 0,
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL,
CHECK (
(parent_id IS NULL AND title <> '' AND hunt_date <> '')
(parent_id IS NULL AND title <> '' AND post_date <> '')
OR
(parent_id IS NOT NULL AND title = '' AND city = '' AND hunt_date = '' AND hidden = 0)
(parent_id IS NOT NULL AND title = '' AND city = '' AND post_date = '' AND hidden = 0)
)
)`},
{"index post replies", `
CREATE INDEX IF NOT EXISTS idx_posts_parent_created
ON posts(parent_id, created_at, id)`},
{"index root posts", `
CREATE INDEX IF NOT EXISTS idx_posts_root_hunt
ON posts(hunt_date, hidden)
CREATE INDEX IF NOT EXISTS idx_posts_root_date
ON posts(post_date, hidden)
WHERE parent_id IS NULL`},
{"create post votes", `
CREATE TABLE IF NOT EXISTS post_votes (
@@ -76,7 +76,7 @@ CREATE TABLE IF NOT EXISTS post_votes (
)`},
{"copy questions", `
INSERT INTO posts (
id, parent_id, author_id, title, body, city, hunt_date, hidden, created_at, updated_at
id, parent_id, author_id, title, body, city, post_date, hidden, created_at, updated_at
)
SELECT
id, NULL, author_id, title, body, city, hunt_date, hidden, created_at, created_at
@@ -84,7 +84,7 @@ FROM questions
ON CONFLICT (id) DO NOTHING`},
{"copy answers", `
INSERT INTO posts (
id, parent_id, author_id, title, body, city, hunt_date, hidden, created_at, updated_at
id, parent_id, author_id, title, body, city, post_date, hidden, created_at, updated_at
)
SELECT
'answer:' || question_id, question_id, author_id, '', body, '', '', 0, created_at, updated_at