Added 'IF NOT EXISTS' clause while creating tables and partition tables which is convenient while using the ERD tool. Fixes #6397
parent
ac403d0dfa
commit
7e79814cb0
|
|
@ -10,6 +10,7 @@ New features
|
|||
************
|
||||
|
||||
| `Issue #6158 <https://redmine.postgresql.org/issues/6158>`_ - Added support to connect PostgreSQL servers via Kerberos authentication.
|
||||
| `Issue #6397 <https://redmine.postgresql.org/issues/6397>`_ - Added "IF NOT EXISTS" clause while creating tables and partition tables which is convenient while using the ERD tool.
|
||||
|
||||
Housekeeping
|
||||
************
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
{#===========================================#}
|
||||
{### CREATE TABLE STATEMENT FOR partitions ###}
|
||||
|
||||
CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE {{conn|qtIdent(data.schema, data.name)}}{% if data.relispartition is defined and data.relispartition %} PARTITION OF {{conn|qtIdent(data.parent_schema, data.partitioned_table_name)}}{% endif %}
|
||||
CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE IF NOT EXISTS {{conn|qtIdent(data.schema, data.name)}}{% if data.relispartition is defined and data.relispartition %} PARTITION OF {{conn|qtIdent(data.parent_schema, data.partitioned_table_name)}}{% endif %}
|
||||
|
||||
{# Macro to render for constraints #}
|
||||
{% if data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 or data.check_constraint|length > 0 or data.exclude_constraint|length > 0 %}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
{#====== MAIN TABLE TEMPLATE STARTS HERE ======#}
|
||||
{#===========================================#}
|
||||
{### CREATE TABLE STATEMENT FOR partitions ###}
|
||||
CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE {{conn|qtIdent(data.schema, data.name)}}{% if data.relispartition is defined and data.relispartition %} PARTITION OF {{conn|qtIdent(data.parent_schema, data.partitioned_table_name)}}{% endif %}
|
||||
CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE IF NOT EXISTS {{conn|qtIdent(data.schema, data.name)}}{% if data.relispartition is defined and data.relispartition %} PARTITION OF {{conn|qtIdent(data.parent_schema, data.partitioned_table_name)}}{% endif %}
|
||||
|
||||
{# Macro to render for constraints #}
|
||||
{% if data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 or data.check_constraint|length > 0 or data.exclude_constraint|length > 0 %}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
{% if data.coll_inherits|length == 0 and data.columns|length == 0 and not data.typname and not data.like_relation and data.primary_key|length == 0 and data.unique_constraint|length == 0 and data.foreign_key|length == 0 and data.check_constraint|length == 0 and data.exclude_constraint|length == 0 %}
|
||||
{% set empty_bracket = "\n(\n)"%}
|
||||
{% endif %}
|
||||
CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE {{conn|qtIdent(data.schema, data.name)}}{{empty_bracket}}
|
||||
CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE IF NOT EXISTS {{conn|qtIdent(data.schema, data.name)}}{{empty_bracket}}
|
||||
{% if data.typname %}
|
||||
OF {{ data.typname }}
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
{% if data.coll_inherits|length == 0 and data.columns|length == 0 and not data.typname and not data.like_relation and data.primary_key|length == 0 and data.unique_constraint|length == 0 and data.foreign_key|length == 0 and data.check_constraint|length == 0 and data.exclude_constraint|length == 0 %}
|
||||
{% set empty_bracket = "\n(\n)"%}
|
||||
{% endif %}
|
||||
CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE {{conn|qtIdent(data.schema, data.name)}}{{empty_bracket}}
|
||||
CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE IF NOT EXISTS {{conn|qtIdent(data.schema, data.name)}}{{empty_bracket}}
|
||||
{% if data.typname %}
|
||||
OF {{ data.typname }}
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
{% if data.fillfactor or data.parallel_workers or data.toast_tuple_target or data.autovacuum_custom or data.autovacuum_enabled in ('t', 'f') or data.toast_autovacuum or data.toast_autovacuum_enabled in ('t', 'f') %}
|
||||
{% set with_clause = true%}
|
||||
{% endif %}
|
||||
CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE {{conn|qtIdent(data.schema, data.name)}}{{empty_bracket}}
|
||||
CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE IF NOT EXISTS {{conn|qtIdent(data.schema, data.name)}}{{empty_bracket}}
|
||||
{% if data.typname %}
|
||||
OF {{ data.typname }}
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
{% if data.coll_inherits|length == 0 and data.columns|length == 0 and not data.typname and not data.like_relation and data.primary_key|length == 0 and data.unique_constraint|length == 0 and data.foreign_key|length == 0 and data.check_constraint|length == 0 and data.exclude_constraint|length == 0 %}
|
||||
{% set empty_bracket = "\n(\n)"%}
|
||||
{% endif %}
|
||||
CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE {{conn|qtIdent(data.schema, data.name)}}{{empty_bracket}}
|
||||
CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE IF NOT EXISTS {{conn|qtIdent(data.schema, data.name)}}{{empty_bracket}}
|
||||
{% if data.typname %}
|
||||
OF {{ data.typname }}
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
{% if data.coll_inherits|length == 0 and data.columns|length == 0 and not data.typname and not data.like_relation and data.primary_key|length == 0 and data.unique_constraint|length == 0 and data.foreign_key|length == 0 and data.check_constraint|length == 0 and data.exclude_constraint|length == 0 %}
|
||||
{% set empty_bracket = "\n(\n)"%}
|
||||
{% endif %}
|
||||
CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE {{conn|qtIdent(data.schema, data.name)}}{{empty_bracket}}
|
||||
CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE IF NOT EXISTS {{conn|qtIdent(data.schema, data.name)}}{{empty_bracket}}
|
||||
{% if data.typname %}
|
||||
OF {{ data.typname }}
|
||||
{% endif %}
|
||||
|
|
|
|||
Loading…
Reference in New Issue