관리자 레이아웃과 네비게이션 정리
This commit is contained in:
23
db/migrations/019_dedupe_navigation_items.sql
Normal file
23
db/migrations/019_dedupe_navigation_items.sql
Normal file
@@ -0,0 +1,23 @@
|
||||
-- 반복 마이그레이션 실행으로 생긴 동일 위치·상위·라벨·URL 메뉴 중복 정리
|
||||
WITH ranked_navigation AS (
|
||||
SELECT
|
||||
id,
|
||||
row_number() OVER (
|
||||
PARTITION BY location, COALESCE(parent_id::text, ''), label, url
|
||||
ORDER BY
|
||||
CASE WHEN is_folder THEN 0 ELSE 1 END,
|
||||
sort_order ASC,
|
||||
created_at ASC,
|
||||
id ASC
|
||||
) AS row_rank
|
||||
FROM navigation_items
|
||||
)
|
||||
DELETE FROM navigation_items
|
||||
WHERE id IN (
|
||||
SELECT id
|
||||
FROM ranked_navigation
|
||||
WHERE row_rank > 1
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS navigation_items_location_parent_label_url_unique_idx
|
||||
ON navigation_items (location, COALESCE(parent_id::text, ''), label, url);
|
||||
Reference in New Issue
Block a user