this repo has no description
1DO $$
2BEGIN
3 IF EXISTS (SELECT 1 FROM pg_type WHERE typname = 'notification_channel') THEN
4 ALTER TYPE notification_channel RENAME TO comms_channel;
5 END IF;
6 IF EXISTS (SELECT 1 FROM pg_type WHERE typname = 'notification_status') THEN
7 ALTER TYPE notification_status RENAME TO comms_status;
8 END IF;
9 IF EXISTS (SELECT 1 FROM pg_type WHERE typname = 'notification_type') THEN
10 ALTER TYPE notification_type RENAME TO comms_type;
11 END IF;
12 IF EXISTS (SELECT 1 FROM pg_tables WHERE tablename = 'notification_queue') THEN
13 ALTER TABLE notification_queue RENAME TO comms_queue;
14 END IF;
15 IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'comms_queue' AND column_name = 'notification_type') THEN
16 ALTER TABLE comms_queue RENAME COLUMN notification_type TO comms_type;
17 END IF;
18 IF EXISTS (SELECT 1 FROM pg_indexes WHERE indexname = 'idx_notification_queue_status_scheduled') THEN
19 ALTER INDEX idx_notification_queue_status_scheduled RENAME TO idx_comms_queue_status_scheduled;
20 END IF;
21 IF EXISTS (SELECT 1 FROM pg_indexes WHERE indexname = 'idx_notification_queue_user_id') THEN
22 ALTER INDEX idx_notification_queue_user_id RENAME TO idx_comms_queue_user_id;
23 END IF;
24 IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'users' AND column_name = 'preferred_notification_channel') THEN
25 ALTER TABLE users RENAME COLUMN preferred_notification_channel TO preferred_comms_channel;
26 END IF;
27END $$;