Files
Memoh/db/migrations/0018_inbox_refactor.down.sql
Acbox Liu fe10abf3fc refactor: inbox (#137)
* refactor: inbox

* fix: migrations

* fix: migrations
2026-02-26 20:16:02 +08:00

12 lines
567 B
SQL

-- 0018_inbox_refactor (down)
-- Revert bot_inbox to original schema: merge header+content back into content JSONB.
-- 1. Convert content back to JSONB, merging header and text.
ALTER TABLE bot_inbox ALTER COLUMN content DROP DEFAULT;
ALTER TABLE bot_inbox ALTER COLUMN content TYPE JSONB USING (COALESCE(header, '{}'::jsonb) || jsonb_build_object('text', content));
ALTER TABLE bot_inbox ALTER COLUMN content SET DEFAULT '{}'::jsonb;
-- 2. Drop added columns.
ALTER TABLE bot_inbox DROP COLUMN IF EXISTS action;
ALTER TABLE bot_inbox DROP COLUMN IF EXISTS header;