You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Test that adjust_column_type expands varchar and decimal columns when
2
+
# the source schema widens. Source starts with VARCHAR(50)/NUMERIC(10,2),
3
+
# then grows to VARCHAR(200)/NUMERIC(18,6). The target should expand
4
+
# column types to match, avoiding truncation or precision loss.
5
+
6
+
steps:
7
+
# 1. Create source table with narrow types
8
+
- id: setup_source
9
+
connection: POSTGRES
10
+
query: |
11
+
DROP TABLE IF EXISTS public.adjust_type_src CASCADE;
12
+
CREATE TABLE public.adjust_type_src (
13
+
id INT PRIMARY KEY,
14
+
name VARCHAR(50),
15
+
amount NUMERIC(10,2),
16
+
description VARCHAR(100)
17
+
);
18
+
INSERT INTO public.adjust_type_src VALUES
19
+
(1, 'short', 123.45, 'short desc'),
20
+
(2, 'test', 678.90, 'another desc');
21
+
22
+
# 2. Create target table with same narrow types (simulating existing target)
23
+
- id: setup_target
24
+
connection: POSTGRES
25
+
query: |
26
+
DROP TABLE IF EXISTS public.adjust_type_tgt CASCADE;
27
+
CREATE TABLE public.adjust_type_tgt (
28
+
id INT,
29
+
name VARCHAR(50),
30
+
amount NUMERIC(10,2),
31
+
description VARCHAR(100)
32
+
);
33
+
INSERT INTO public.adjust_type_tgt VALUES
34
+
(1, 'short', 123.45, 'short desc'),
35
+
(2, 'test', 678.90, 'another desc');
36
+
37
+
# 3. Widen source columns and insert data that needs wider columns
38
+
- id: widen_source
39
+
connection: POSTGRES
40
+
query: |
41
+
ALTER TABLE public.adjust_type_src ALTER COLUMN name TYPE VARCHAR(200);
42
+
ALTER TABLE public.adjust_type_src ALTER COLUMN amount TYPE NUMERIC(18,6);
43
+
ALTER TABLE public.adjust_type_src ALTER COLUMN description TYPE VARCHAR(500);
44
+
INSERT INTO public.adjust_type_src VALUES
45
+
(3, 'this is a much longer name that exceeds fifty characters easily and needs expansion', 123456789.123456, 'this description is long enough to exceed one hundred characters and requires the target column to be expanded to avoid any truncation errors in the database');
0 commit comments