File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
dbt/include/sqlserver/macros/adapters Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change 46
46
{%- set tmp_column = column_name + " __dbt_alter" - %}
47
47
48
48
{% call statement(' alter_column_type' ) - %}
49
-
50
- alter {{ relation .type }} {{ relation }} add {{ tmp_column }} {{ new_column_type }};
51
- update {{ relation }} set {{ tmp_column }} = {{ column_name }};
52
- alter {{ relation .type }} {{ relation }} drop column {{ column_name }};
49
+ alter {{ relation .type }} {{ relation }} add " {{ tmp_column }}" {{ new_column_type }};
50
+ {%- endcall - %}
51
+ {% call statement(' alter_column_type' ) - %}
52
+ update {{ relation }} set " {{ tmp_column }}" = " {{ column_name }}" ;
53
+ {%- endcall - %}
54
+ {% call statement(' alter_column_type' ) - %}
55
+ alter {{ relation .type }} {{ relation }} drop column " {{ column_name }}" ;
56
+ {%- endcall - %}
57
+ {% call statement(' alter_column_type' ) - %}
53
58
exec sp_rename ' {{ relation | replace(' " ', '') }}.{{ tmp_column }}', '{{ column_name }}', 'column'
54
-
55
59
{%- endcall -%}
56
60
57
61
{% endmacro %}
61
65
{% call statement('add_drop_columns') -%}
62
66
{% if add_columns %}
63
67
alter {{ relation.type }} {{ relation }}
64
- add {% for column in add_columns %}{{ column.name }} {{ column.data_type }}{{ ', ' if not loop.last }}{% endfor %};
68
+ add {% for column in add_columns %}" {{ column .name }}" {{ column.data_type }}{{ ', ' if not loop.last }}{% endfor %};
65
69
{% endif %}
66
70
67
71
{% if remove_columns %}
68
72
alter {{ relation.type }} {{ relation }}
69
- drop column {% for column in remove_columns %}{{ column.name }}{{ ',' if not loop.last }}{% endfor %};
73
+ drop column {% for column in remove_columns %}" {{ column .name }}" {{ ',' if not loop.last }}{% endfor %};
70
74
{% endif %}
71
75
{%- endcall -%}
72
76
{% endmacro %}
You can’t perform that action at this time.
0 commit comments