Skip to content

Commit efe1bcb

Browse files
vigyuvsdebruyn
authored andcommitted
updates the create schema statement
Adds authorization based on the create schema syntax defined by Microsoft. https://docs.microsoft.com/en-us/sql/t-sql/statements/create-schema-transact-sql?view=sql-server-ver15#remarks
1 parent e81f138 commit efe1bcb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

dbt/include/sqlserver/macros/adapters/schema.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{% macro sqlserver__create_schema(relation) -%}
2+
{% auth = config.get("auth") %}
23
{% call statement('create_schema') -%}
34
USE [{{ relation.database }}];
45
IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = '{{ relation.without_identifier().schema }}')
56
BEGIN
6-
EXEC('CREATE SCHEMA [{{ relation.without_identifier().schema }}]')
7+
EXEC('CREATE SCHEMA [{{ relation.without_identifier().schema }}] {%- if auth -%} AUTHORIZATION: [{{auth}}]')
78
END
89
{% endcall %}
910
{% endmacro %}

0 commit comments

Comments
 (0)