-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoconnor-26.000-26.001.sql
More file actions
42 lines (41 loc) · 1.1 KB
/
oconnor-26.000-26.001.sql
File metadata and controls
42 lines (41 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
DO $$
DECLARE
rec RECORD;
BEGIN
FOR rec IN
SELECT c.table_name, c.column_name
FROM information_schema.columns c
JOIN information_schema.tables t ON t.table_schema = c.table_schema AND t.table_name = c.table_name
WHERE c.table_schema = 'oconnor'
AND t.table_type = 'BASE TABLE'
AND lower(c.column_name) IN ('createdby',
'modifiedby')
AND c.data_type = 'smallint'
LOOP
EXECUTE format(
'ALTER TABLE oconnor.%I ALTER COLUMN %I
TYPE userid',
rec.table_name, rec.column_name
);
END LOOP;
END $$;
DO $$
DECLARE
rec RECORD;
BEGIN
FOR rec IN
SELECT c.table_name, c.column_name
FROM information_schema.columns c
JOIN information_schema.tables t ON t.table_schema = c.table_schema AND t.table_name = c.table_name
WHERE c.table_schema = 'oconnor'
AND t.table_type = 'BASE TABLE'
AND lower(c.column_name) = 'container'
AND c.data_type = 'character varying'
LOOP
EXECUTE format(
'ALTER TABLE oconnor.%I ALTER COLUMN %I
TYPE entityid',
rec.table_name, rec.column_name
);
END LOOP;
END $$;