태그를 관리용/일반용으로 분리하고 관리자 드래그 정렬을 추가.
댓글/회원/관리자 인증·프로필 흐름 보완과 관련 마이그레이션 및 문서를 함께 반영해 운영 동선을 안정화. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
9
db/migrations/012_add_comment_likes.sql
Normal file
9
db/migrations/012_add_comment_likes.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
CREATE TABLE IF NOT EXISTS comment_likes (
|
||||
comment_id UUID NOT NULL REFERENCES comments(id) ON DELETE CASCADE,
|
||||
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (comment_id, user_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS comment_likes_user_id_idx
|
||||
ON comment_likes (user_id);
|
||||
12
db/migrations/013_add_user_admin_role.sql
Normal file
12
db/migrations/013_add_user_admin_role.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
ALTER TABLE users
|
||||
ADD COLUMN IF NOT EXISTS is_admin BOOLEAN NOT NULL DEFAULT false;
|
||||
|
||||
WITH first_user AS (
|
||||
SELECT id
|
||||
FROM users
|
||||
ORDER BY created_at ASC, id ASC
|
||||
LIMIT 1
|
||||
)
|
||||
UPDATE users
|
||||
SET is_admin = true
|
||||
WHERE id IN (SELECT id FROM first_user);
|
||||
27
db/migrations/014_add_user_role_levels.sql
Normal file
27
db/migrations/014_add_user_role_levels.sql
Normal file
@@ -0,0 +1,27 @@
|
||||
ALTER TABLE users
|
||||
ADD COLUMN IF NOT EXISTS user_role TEXT NOT NULL DEFAULT 'member';
|
||||
|
||||
UPDATE users
|
||||
SET user_role = CASE
|
||||
WHEN is_admin THEN 'admin'
|
||||
ELSE 'member'
|
||||
END
|
||||
WHERE user_role NOT IN ('owner', 'admin', 'member');
|
||||
|
||||
WITH first_user AS (
|
||||
SELECT id
|
||||
FROM users
|
||||
ORDER BY created_at ASC, id ASC
|
||||
LIMIT 1
|
||||
)
|
||||
UPDATE users
|
||||
SET user_role = 'owner'
|
||||
WHERE id IN (SELECT id FROM first_user)
|
||||
AND is_admin = true;
|
||||
|
||||
ALTER TABLE users
|
||||
DROP CONSTRAINT IF EXISTS users_user_role_check;
|
||||
|
||||
ALTER TABLE users
|
||||
ADD CONSTRAINT users_user_role_check
|
||||
CHECK (user_role IN ('owner', 'admin', 'member'));
|
||||
13
db/migrations/015_add_tag_type_and_reorder_support.sql
Normal file
13
db/migrations/015_add_tag_type_and_reorder_support.sql
Normal file
@@ -0,0 +1,13 @@
|
||||
ALTER TABLE tags
|
||||
ADD COLUMN IF NOT EXISTS tag_type TEXT NOT NULL DEFAULT 'managed';
|
||||
|
||||
UPDATE tags
|
||||
SET tag_type = 'managed'
|
||||
WHERE tag_type NOT IN ('managed', 'general');
|
||||
|
||||
ALTER TABLE tags
|
||||
DROP CONSTRAINT IF EXISTS tags_tag_type_check;
|
||||
|
||||
ALTER TABLE tags
|
||||
ADD CONSTRAINT tags_tag_type_check
|
||||
CHECK (tag_type IN ('managed', 'general'));
|
||||
Reference in New Issue
Block a user