Skip to content

Commit 7e8a887

Browse files
committed
RHINENG-26529: undo failed schema migration
1 parent b4762d3 commit 7e8a887

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-- noop
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
DO $$
2+
BEGIN
3+
IF EXISTS (SELECT 1 FROM pg_attribute a
4+
JOIN pg_class c ON c.oid = a.attrelid
5+
JOIN pg_namespace n ON n.oid = c.relnamespace
6+
WHERE n.nspname = 'public' AND c.relname = 'system_inventory' AND a.attname = 'workspace_id'
7+
AND a.attnum > 0 AND NOT a.attisdropped)
8+
THEN
9+
ALTER TABLE system_inventory
10+
ADD COLUMN workspaces JSONB;
11+
12+
UPDATE system_inventory
13+
SET workspaces = JSONB_BUILD_ARRAY(JSONB_BUILD_OBJECT('id', workspace_id, 'name', workspace_name));
14+
15+
CREATE INDEX IF NOT EXISTS system_inventory_workspaces_index ON system_inventory USING GIN (workspaces);
16+
17+
ALTER TABLE system_inventory
18+
DROP COLUMN workspace_id,
19+
DROP COLUMN workspace_name;
20+
END IF;
21+
END $$;
22+

database_admin/schema/create_schema.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ CREATE TABLE IF NOT EXISTS schema_migrations
77

88

99
INSERT INTO schema_migrations
10-
VALUES (152, false);
10+
VALUES (154, false);
1111

1212
-- ---------------------------------------------------------------------------
1313
-- Functions

0 commit comments

Comments
 (0)