{% if data %}
{% if not data.lc_collate and not data.lc_type and not data.locale and not data.copy_collation %}
CREATE COLLATION {{ conn|qtIdent(data.schema, data.name) }}
    FROM pg_catalog."default";
{% else %}
CREATE COLLATION {{ conn|qtIdent(data.schema, data.name) }}
{% endif %}
{# if user has provided lc_collate & lc_type #}
{% if data.lc_collate and data.lc_type %}
    (LC_COLLATE = {{ data.lc_collate|qtLiteral }}, LC_CTYPE = {{ data.lc_type|qtLiteral }});
{% endif %}
{# if user has provided locale only  #}
{% if data.locale %}
    (LOCALE = {{ data.locale|qtLiteral }});
{% endif %}
{# if user has choosed to copy from existing collation #}
{% if data.copy_collation %}
    FROM {{ data.copy_collation }};
{% endif %}
{% if data.owner %}

ALTER COLLATION {{ conn|qtIdent(data.schema, data.name) }}
    OWNER TO {{ conn|qtIdent(data.owner) }};
{% endif %}
{% if data.description %}

COMMENT ON COLLATION {{ conn|qtIdent(data.schema, data.name) }}
    IS {{ data.description|qtLiteral }};
{% endif %}
{% endif %}
