2025-01-29 02:21:51 +08:00
|
|
|
-- This file should undo anything in `up.sql`
|
2025-03-08 00:19:47 +08:00
|
|
|
-- Drop indexes first
|
|
|
|
DROP INDEX IF EXISTS messages_chat_id_idx;
|
|
|
|
DROP INDEX IF EXISTS messages_created_by_idx;
|
|
|
|
DROP INDEX IF EXISTS messages_created_at_idx;
|
2025-01-29 03:03:11 +08:00
|
|
|
|
|
|
|
-- Drop new messages table
|
|
|
|
DROP TABLE messages;
|
|
|
|
|
|
|
|
-- Rename deprecated table back to messages
|
|
|
|
ALTER TABLE messages_deprecated RENAME TO messages;
|
2025-03-08 00:19:47 +08:00
|
|
|
|
|
|
|
-- Drop existing constraint if it exists
|
|
|
|
ALTER TABLE messages
|
|
|
|
DROP CONSTRAINT IF EXISTS messages_thread_id_fkey;
|
|
|
|
|
|
|
|
-- Restore foreign key constraint
|
|
|
|
ALTER TABLE messages
|
|
|
|
ADD CONSTRAINT messages_thread_id_fkey
|
|
|
|
FOREIGN KEY (thread_id) REFERENCES threads(id);
|