Skip to content

Commit 746859a

Browse files
committed
Add an upgrade script to update 'createdBy' and 'modifiedBy' column types from smallint (int2) to userid (int4).
1 parent f4de40b commit 746859a

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

OConnor/module.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Name: OConnor
2-
SchemaVersion: 25.001
2+
SchemaVersion: 26.001
33
RequiredServerVersion: 16.30
44
ManageVersion: true
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
DO $$
2+
DECLARE
3+
rec RECORD;
4+
BEGIN
5+
FOR rec IN
6+
SELECT table_name, column_name
7+
FROM information_schema.columns
8+
WHERE table_schema = 'oconnor'
9+
AND lower(column_name) IN ('createdby',
10+
'modifiedby')
11+
AND data_type = 'smallint'
12+
LOOP
13+
EXECUTE format(
14+
'ALTER TABLE oconnor.%I ALTER COLUMN %I
15+
TYPE userid',
16+
rec.table_name, rec.column_name
17+
);
18+
END LOOP;
19+
END $$;

0 commit comments

Comments
 (0)