-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadd-visibility-column.sql
More file actions
28 lines (22 loc) · 1.03 KB
/
add-visibility-column.sql
File metadata and controls
28 lines (22 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
-- Add visibility column to podcasts table
-- This script adds a visibility column to support public, private, and unlisted podcasts
-- Add the visibility column with default value of 'public'
ALTER TABLE podcasts
ADD COLUMN visibility TEXT DEFAULT 'public';
-- Add a check constraint to ensure only valid visibility values
ALTER TABLE podcasts
ADD CONSTRAINT visibility_check
CHECK (visibility IN ('public', 'private', 'unlisted'));
-- Update any existing NULL values to 'public' (just in case)
UPDATE podcasts
SET visibility = 'public'
WHERE visibility IS NULL;
-- Create an index on visibility for better query performance
CREATE INDEX IF NOT EXISTS idx_podcasts_visibility ON podcasts(visibility);
-- Create a composite index for common queries (status + visibility)
CREATE INDEX IF NOT EXISTS idx_podcasts_status_visibility ON podcasts(status, visibility);
-- Verify the changes
SELECT column_name, data_type, is_nullable, column_default
FROM information_schema.columns
WHERE table_name = 'podcasts'
AND column_name = 'visibility';