Files
taxbaik/db/migrations/V027__BlogSoftDeleteAndSlugIndex.sql
T
kjh2064 cb47349a25
TaxBaik CI/CD / build-and-deploy (push) Has been cancelled
feat(admin): stabilize blog and admin patterns
2026-07-02 10:46:27 +09:00

22 lines
626 B
SQL

ALTER TABLE blog_posts
ADD COLUMN IF NOT EXISTS deleted_at TIMESTAMPTZ;
DROP INDEX IF EXISTS idx_blog_slug;
DROP INDEX IF EXISTS blog_posts_slug_key;
CREATE UNIQUE INDEX IF NOT EXISTS ux_blog_posts_slug_active
ON blog_posts (slug)
WHERE deleted_at IS NULL;
CREATE INDEX IF NOT EXISTS idx_blog_slug_active
ON blog_posts (slug)
WHERE deleted_at IS NULL;
CREATE INDEX IF NOT EXISTS idx_blog_published_active
ON blog_posts (is_published, published_at DESC)
WHERE deleted_at IS NULL;
CREATE INDEX IF NOT EXISTS idx_blog_category_active
ON blog_posts (category_id)
WHERE deleted_at IS NULL;