feat: add admin apis

This commit is contained in:
Krispire Admin
2026-06-16 14:47:45 +05:30
parent aa61f4f0b1
commit a49bf7591e
24 changed files with 1164 additions and 22 deletions
+18
View File
@@ -0,0 +1,18 @@
-- Soft-delete (admin moderation) for posts and comments. Additive: the column
-- is nullable and defaults to NULL, and every read query now filters
-- `deleted_at IS NULL` — a no-op for existing rows (all NULL), so nothing in
-- the live app changes until an admin actually deletes something. A soft-
-- deleted row disappears from all reads but stays in the table, recoverable
-- via the admin "restore" action.
ALTER TABLE posts
ADD COLUMN IF NOT EXISTS deleted_at TIMESTAMPTZ;
ALTER TABLE post_comments
ADD COLUMN IF NOT EXISTS deleted_at TIMESTAMPTZ;
-- Partial indexes keep the hot "not deleted" reads fast (they match the
-- deleted_at IS NULL predicate now on every posts/comments query).
CREATE INDEX IF NOT EXISTS posts_not_deleted_idx
ON posts (created_at DESC) WHERE deleted_at IS NULL;
CREATE INDEX IF NOT EXISTS post_comments_not_deleted_idx
ON post_comments (post_id) WHERE deleted_at IS NULL;