mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed schema diff wrong query generation for table, foreign table and sequence. #7165
This commit is contained in:
parent
30398219f4
commit
bece59d4b3
@ -13,7 +13,6 @@ CREATE FOREIGN TABLE{% if add_not_exists_clause %} IF NOT EXISTS{% endif %} {{ c
|
||||
{% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral(conn)}}{% if loop.last %}){% endif %}{% endif %}
|
||||
{% endfor %}{% endif %}
|
||||
{% if c.attnotnull %} NOT NULL{% endif %}
|
||||
{% if c.defval is defined and c.defval is not none and c.defval != '' and c.colconstype != 'g' %} DEFAULT {{c.defval}}{% endif %}
|
||||
{% if c.colconstype == 'g' and c.genexpr and c.genexpr != '' %}
|
||||
GENERATED ALWAYS AS {{c.genexpr}} STORED{% endif %}
|
||||
{% if c.collname %} COLLATE {{c.collname}}{% endif %}
|
||||
@ -80,27 +79,33 @@ COMMENT ON COLUMN {{conn|qtIdent(data.basensp, data.name, c.name)}}
|
||||
{#===========================================#}
|
||||
{% if data.columns and data.columns|length > 0 %}
|
||||
{% for c in data.columns %}
|
||||
{### Alter SQL for adding sequence to column ###}
|
||||
{% if c.defval is defined and c.defval is not none and c.defval != '' and c.colconstype != 'g' %}
|
||||
ALTER FOREIGN TABLE IF EXISTS ONLY {{conn|qtIdent(data.basensp, data.name)}}
|
||||
ALTER COLUMN {{conn|qtIdent(c.name)}} SET DEFAULT {{c.defval}};
|
||||
{% endif %}
|
||||
{% if c.description %}
|
||||
|
||||
COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.name, c.name)}}
|
||||
COMMENT ON COLUMN {{conn|qtIdent(data.basensp, data.name, c.name)}}
|
||||
IS {{c.description|qtLiteral(conn)}};
|
||||
{% endif %}
|
||||
{### Add variables to column ###}
|
||||
{% if c.attoptions and c.attoptions|length > 0 %}
|
||||
|
||||
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}}
|
||||
ALTER FOREIGN TABLE IF EXISTS {{conn|qtIdent(data.basensp, data.name)}}
|
||||
{{ VARIABLE.SET(conn, 'COLUMN', c.name, c.attoptions) }}
|
||||
|
||||
{% endif %}
|
||||
{### Alter column statistics value ###}
|
||||
{% if c.attstattarget is defined and c.attstattarget > -1 %}
|
||||
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}}
|
||||
ALTER FOREIGN TABLE IF EXISTS {{conn|qtIdent(data.basensp, data.name)}}
|
||||
ALTER COLUMN {{conn|qtTypeIdent(c.name)}} SET STATISTICS {{c.attstattarget}};
|
||||
|
||||
{% endif %}
|
||||
{### Alter column storage value ###}
|
||||
{% if c.attstorage is defined and c.attstorage != c.defaultstorage %}
|
||||
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}}
|
||||
|
||||
ALTER FOREIGN TABLE IF EXISTS {{conn|qtIdent(data.basensp, data.name)}}
|
||||
ALTER COLUMN {{conn|qtTypeIdent(c.name)}} SET STORAGE {%if c.attstorage == 'p' %}
|
||||
PLAIN{% elif c.attstorage == 'm'%}MAIN{% elif c.attstorage == 'e'%}
|
||||
EXTERNAL{% elif c.attstorage == 'x'%}EXTENDED{% endif %};
|
||||
|
@ -22,5 +22,5 @@ GRANT SELECT ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
|
||||
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO postgres;
|
||||
|
||||
|
||||
ALTER TABLE IF EXISTS "FT1_$%{}[]()&*^!@""'`\/#"
|
||||
ALTER FOREIGN TABLE IF EXISTS public."FT1_$%{}[]()&*^!@""'`\/#"
|
||||
ALTER COLUMN col1 SET STATISTICS 10;
|
||||
|
@ -17,5 +17,5 @@ COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
|
||||
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO postgres;
|
||||
|
||||
|
||||
ALTER TABLE IF EXISTS "FT1_$%{}[]()&*^!@""'`\/#"
|
||||
ALTER FOREIGN TABLE IF EXISTS public."FT1_$%{}[]()&*^!@""'`\/#"
|
||||
ALTER COLUMN col1 SET STATISTICS 10;
|
||||
|
@ -22,5 +22,5 @@ GRANT SELECT ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
|
||||
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO enterprisedb;
|
||||
|
||||
|
||||
ALTER TABLE IF EXISTS "FT1_$%{}[]()&*^!@""'`\/#"
|
||||
ALTER FOREIGN TABLE IF EXISTS public."FT1_$%{}[]()&*^!@""'`\/#"
|
||||
ALTER COLUMN col1 SET STATISTICS 10;
|
||||
|
@ -17,5 +17,5 @@ COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
|
||||
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO enterprisedb;
|
||||
|
||||
|
||||
ALTER TABLE IF EXISTS "FT1_$%{}[]()&*^!@""'`\/#"
|
||||
ALTER FOREIGN TABLE IF EXISTS public."FT1_$%{}[]()&*^!@""'`\/#"
|
||||
ALTER COLUMN col1 SET STATISTICS 10;
|
||||
|
@ -12,7 +12,10 @@ CREATE {% if data.relpersistence %}UNLOGGED {% endif %}SEQUENCE{% if add_not_exi
|
||||
|
||||
MAXVALUE {{data.maximum|int}}{% endif %}{% if data.cache is defined and data.cache|int(-1) > -1%}
|
||||
|
||||
CACHE {{data.cache|int}}{% endif %}{% if data.owned_table is defined and data.owned_table != None and data.owned_column is defined and data.owned_column != None %}
|
||||
|
||||
OWNED BY {{ conn|qtIdent(data.schema) }}.{{ conn|qtIdent(data.owned_table) }}.{{ conn|qtIdent(data.owned_column) }}{% endif %};
|
||||
CACHE {{data.cache|int}}{% endif %};
|
||||
{### Alter SQL for adding OWNED BY to sequence ###}
|
||||
{% if data.owned_table is defined and data.owned_table != None and data.owned_column is defined and data.owned_column != None %}
|
||||
|
||||
ALTER SEQUENCE {{ conn|qtIdent(data.schema, data.name) }}
|
||||
OWNED BY {{ conn|qtIdent(data.schema) }}.{{ conn|qtIdent(data.owned_table) }}.{{ conn|qtIdent(data.owned_column) }};
|
||||
{% endif %}
|
||||
|
@ -11,12 +11,12 @@ ALTER SEQUENCE IF EXISTS {{ conn|qtIdent(o_data.schema, data.name) }}
|
||||
OWNER TO {{ conn|qtIdent(data.seqowner) }};
|
||||
|
||||
{% endif %}
|
||||
{% if (data.owned_table == None) and (data.owned_column == None) %}
|
||||
{% if (data.owned_table == None and data.owned_column == None) or (data.owned_table == '' and data.owned_column == '')%}
|
||||
ALTER SEQUENCE IF EXISTS {{ conn|qtIdent(o_data.schema, data.name) }}
|
||||
OWNED BY NONE;
|
||||
{% elif (data.owned_table is defined or data.owned_column is defined) and (data.owned_table != o_data.owned_table or data.owned_column != o_data.owned_column) %}
|
||||
ALTER SEQUENCE IF EXISTS {{ conn|qtIdent(o_data.schema, data.name) }}
|
||||
OWNED BY {% if data.owned_table is defined %}{{ conn|qtIdent(data.owned_table) }}{% else %}{{ conn|qtIdent(o_data.owned_table) }}{% endif %}.{% if data.owned_column is defined %}{{ conn|qtIdent(data.owned_column) }}{% else %}{{ conn|qtIdent(o_data.owned_column) }}{% endif %};
|
||||
OWNED BY {{ conn|qtIdent(o_data.schema) }}.{% if data.owned_table is defined %}{{ conn|qtIdent(data.owned_table) }}{% else %}{{ conn|qtIdent(o_data.owned_table) }}{% endif %}.{% if data.owned_column is defined %}{{ conn|qtIdent(data.owned_column) }}{% else %}{{ conn|qtIdent(o_data.owned_column) }}{% endif %};
|
||||
{% endif %}
|
||||
{% if data.current_value is defined %}
|
||||
{% set seqname = conn|qtIdent(o_data.schema, data.name) %}
|
||||
|
@ -12,7 +12,10 @@ CREATE SEQUENCE{% if add_not_exists_clause %} IF NOT EXISTS{% endif %} {{ conn|q
|
||||
|
||||
MAXVALUE {{data.maximum|int}}{% endif %}{% if data.cache is defined and data.cache|int(-1) > -1%}
|
||||
|
||||
CACHE {{data.cache|int}}{% endif %}{% if data.owned_table is defined and data.owned_table != None and data.owned_column is defined and data.owned_column != None %}
|
||||
|
||||
OWNED BY {{ conn|qtIdent(data.schema) }}.{{ conn|qtIdent(data.owned_table) }}.{{ conn|qtIdent(data.owned_column) }}{% endif %};
|
||||
CACHE {{data.cache|int}}{% endif %};
|
||||
{### Alter SQL for adding OWNED BY to sequence ###}
|
||||
{% if data.owned_table is defined and data.owned_table != None and data.owned_column is defined and data.owned_column != None %}
|
||||
|
||||
ALTER SEQUENCE {{ conn|qtIdent(data.schema, data.name) }}
|
||||
OWNED BY {{ conn|qtIdent(data.schema) }}.{{ conn|qtIdent(data.owned_table) }}.{{ conn|qtIdent(data.owned_column) }};
|
||||
{% endif %}
|
||||
|
@ -11,12 +11,12 @@ ALTER SEQUENCE IF EXISTS {{ conn|qtIdent(o_data.schema, data.name) }}
|
||||
OWNER TO {{ conn|qtIdent(data.seqowner) }};
|
||||
|
||||
{% endif %}
|
||||
{% if (data.owned_table == None) and (data.owned_column == None) %}
|
||||
{% if (data.owned_table == None and data.owned_column == None) or (data.owned_table == '' and data.owned_column == '') %}
|
||||
ALTER SEQUENCE IF EXISTS {{ conn|qtIdent(o_data.schema, data.name) }}
|
||||
OWNED BY NONE;
|
||||
{% elif (data.owned_table is defined or data.owned_column is defined) and (data.owned_table != o_data.owned_table or data.owned_column != o_data.owned_column) %}
|
||||
ALTER SEQUENCE IF EXISTS {{ conn|qtIdent(o_data.schema, data.name) }}
|
||||
OWNED BY {% if data.owned_table is defined %}{{ conn|qtIdent(data.owned_table) }}{% else %}{{ conn|qtIdent(o_data.owned_table) }}{% endif %}.{% if data.owned_column is defined %}{{ conn|qtIdent(data.owned_column) }}{% else %}{{ conn|qtIdent(o_data.owned_column) }}{% endif %};
|
||||
OWNED BY {{ conn|qtIdent(o_data.schema) }}.{% if data.owned_table is defined %}{{ conn|qtIdent(data.owned_table) }}{% else %}{{ conn|qtIdent(o_data.owned_table) }}{% endif %}.{% if data.owned_column is defined %}{{ conn|qtIdent(data.owned_column) }}{% else %}{{ conn|qtIdent(o_data.owned_column) }}{% endif %};
|
||||
{% endif %}
|
||||
{% if data.current_value is defined %}
|
||||
{% set seqname = conn|qtIdent(o_data.schema, data.name) %}
|
||||
|
@ -284,7 +284,8 @@
|
||||
"sql_endpoint": "NODE-sequence.sql_id",
|
||||
"msql_endpoint": "NODE-sequence.msql_id",
|
||||
"data": {
|
||||
"maximum": "900"
|
||||
"owned_table": "",
|
||||
"owned_column": ""
|
||||
},
|
||||
"expected_sql_file": "alter_ownedby_remove.sql",
|
||||
"expected_msql_file": "alter_ownedby_remove_msql.sql"
|
||||
@ -349,4 +350,3 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -7,7 +7,9 @@ CREATE SEQUENCE IF NOT EXISTS public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
START 5
|
||||
MINVALUE 5
|
||||
MAXVALUE 999
|
||||
CACHE 1
|
||||
CACHE 1;
|
||||
|
||||
ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
OWNED BY public.tableforownedby.col2;
|
||||
|
||||
ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
|
@ -1,2 +1,2 @@
|
||||
ALTER SEQUENCE IF EXISTS public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
OWNED BY tableforownedby.col2;
|
||||
OWNED BY public.tableforownedby.col2;
|
||||
|
@ -6,9 +6,8 @@ CREATE SEQUENCE IF NOT EXISTS public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
INCREMENT 5
|
||||
START 5
|
||||
MINVALUE 5
|
||||
MAXVALUE 900
|
||||
CACHE 1
|
||||
OWNED BY public.tableforownedby.col2;
|
||||
MAXVALUE 999
|
||||
CACHE 1;
|
||||
|
||||
ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
OWNER TO postgres;
|
||||
|
@ -1,2 +1,2 @@
|
||||
ALTER SEQUENCE IF EXISTS public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
MAXVALUE 900;
|
||||
OWNED BY NONE;
|
||||
|
@ -7,7 +7,9 @@ CREATE SEQUENCE IF NOT EXISTS public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
START 5
|
||||
MINVALUE 5
|
||||
MAXVALUE 999
|
||||
CACHE 1
|
||||
CACHE 1;
|
||||
|
||||
ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
OWNED BY public.tableforownedby.col1;
|
||||
|
||||
ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
|
@ -3,7 +3,9 @@ CREATE SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
START 5
|
||||
MINVALUE 5
|
||||
MAXVALUE 999
|
||||
CACHE 1
|
||||
CACHE 1;
|
||||
|
||||
ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
OWNED BY public.tableforownedby.col1;
|
||||
|
||||
ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
|
@ -1,13 +0,0 @@
|
||||
-- SEQUENCE: public.Seq1_$%{}[]()&*^!@"'`\/#
|
||||
|
||||
-- DROP SEQUENCE IF EXISTS public."Seq1_$%{}[]()&*^!@""'`\/#";
|
||||
|
||||
CREATE SEQUENCE IF NOT EXISTS public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
INCREMENT 5
|
||||
START 5
|
||||
MINVALUE 5
|
||||
MAXVALUE 999
|
||||
CACHE 1;
|
||||
|
||||
ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
OWNER TO postgres;
|
@ -67,7 +67,12 @@
|
||||
"sql_endpoint": "NODE-sequence.sql_id",
|
||||
"msql_endpoint": "NODE-sequence.msql_id",
|
||||
"data": {
|
||||
"current_value": "7", "increment": "12", "minimum": "2", "maximum": "9992", "cache": "2", "cycled": true
|
||||
"current_value": "7",
|
||||
"increment": "12",
|
||||
"minimum": "2",
|
||||
"maximum": "9992",
|
||||
"cache": "2",
|
||||
"cycled": true
|
||||
},
|
||||
"expected_sql_file": "alter_seq_props.sql",
|
||||
"expected_msql_file": "alter_seq_props_msql.sql"
|
||||
@ -124,26 +129,6 @@
|
||||
"expected_sql_file": "alter_seq_privs_update.sql",
|
||||
"expected_msql_file": "alter_seq_privs_update_msql.sql"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter Sequence remove partial privileges",
|
||||
"endpoint": "NODE-sequence.obj_id",
|
||||
"sql_endpoint": "NODE-sequence.sql_id",
|
||||
"msql_endpoint": "NODE-sequence.msql_id",
|
||||
"data": {
|
||||
"relacl": {
|
||||
"deleted":[{
|
||||
"grantee": "PUBLIC",
|
||||
"grantor": "postgres",
|
||||
"privileges":[{
|
||||
"privilege_type": "r",
|
||||
"privilege": true,
|
||||
"with_grant": false
|
||||
}]
|
||||
}]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter Sequence change grantee in privileges",
|
||||
@ -284,7 +269,8 @@
|
||||
"sql_endpoint": "NODE-sequence.sql_id",
|
||||
"msql_endpoint": "NODE-sequence.msql_id",
|
||||
"data": {
|
||||
"maximum": "900"
|
||||
"owned_table": "",
|
||||
"owned_column": ""
|
||||
},
|
||||
"expected_sql_file": "alter_ownedby_remove.sql",
|
||||
"expected_msql_file": "alter_ownedby_remove_msql.sql"
|
||||
|
@ -282,7 +282,8 @@
|
||||
"sql_endpoint": "NODE-sequence.sql_id",
|
||||
"msql_endpoint": "NODE-sequence.msql_id",
|
||||
"data": {
|
||||
"maximum": "900"
|
||||
"owned_table": "",
|
||||
"owned_column": ""
|
||||
},
|
||||
"expected_sql_file": "alter_ownedby_remove.sql",
|
||||
"expected_msql_file": "alter_ownedby_remove_msql.sql"
|
||||
@ -347,4 +348,3 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -7,7 +7,9 @@ CREATE SEQUENCE IF NOT EXISTS public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
START 5
|
||||
MINVALUE 5
|
||||
MAXVALUE 999
|
||||
CACHE 1
|
||||
CACHE 1;
|
||||
|
||||
ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
OWNED BY public.tableforownedby.col2;
|
||||
|
||||
ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
|
@ -1,2 +1,2 @@
|
||||
ALTER SEQUENCE IF EXISTS public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
OWNED BY tableforownedby.col2;
|
||||
OWNED BY public.tableforownedby.col2;
|
||||
|
@ -6,9 +6,8 @@ CREATE SEQUENCE IF NOT EXISTS public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
INCREMENT 5
|
||||
START 5
|
||||
MINVALUE 5
|
||||
MAXVALUE 900
|
||||
CACHE 1
|
||||
OWNED BY public.tableforownedby.col2;
|
||||
MAXVALUE 999
|
||||
CACHE 1;
|
||||
|
||||
ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
OWNER TO enterprisedb;
|
||||
|
@ -1,2 +1,2 @@
|
||||
ALTER SEQUENCE IF EXISTS public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
MAXVALUE 900;
|
||||
OWNED BY NONE;
|
||||
|
@ -7,7 +7,9 @@ CREATE SEQUENCE IF NOT EXISTS public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
START 5
|
||||
MINVALUE 5
|
||||
MAXVALUE 999
|
||||
CACHE 1
|
||||
CACHE 1;
|
||||
|
||||
ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
OWNED BY public.tableforownedby.col1;
|
||||
|
||||
ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
|
@ -3,7 +3,9 @@ CREATE SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
START 5
|
||||
MINVALUE 5
|
||||
MAXVALUE 999
|
||||
CACHE 1
|
||||
CACHE 1;
|
||||
|
||||
ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
OWNED BY public.tableforownedby.col1;
|
||||
|
||||
ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
|
@ -1,13 +0,0 @@
|
||||
-- SEQUENCE: public.Seq1_$%{}[]()&*^!@"'`\/#
|
||||
|
||||
-- DROP SEQUENCE IF EXISTS public."Seq1_$%{}[]()&*^!@""'`\/#";
|
||||
|
||||
CREATE SEQUENCE IF NOT EXISTS public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
INCREMENT 5
|
||||
START 5
|
||||
MINVALUE 5
|
||||
MAXVALUE 999
|
||||
CACHE 1;
|
||||
|
||||
ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
OWNER TO enterprisedb;
|
@ -122,26 +122,6 @@
|
||||
"expected_sql_file": "alter_seq_privs_update.sql",
|
||||
"expected_msql_file": "alter_seq_privs_update_msql.sql"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter Sequence remove partial privileges",
|
||||
"endpoint": "NODE-sequence.obj_id",
|
||||
"sql_endpoint": "NODE-sequence.sql_id",
|
||||
"msql_endpoint": "NODE-sequence.msql_id",
|
||||
"data": {
|
||||
"relacl": {
|
||||
"deleted":[{
|
||||
"grantee": "PUBLIC",
|
||||
"grantor": "enterprisedb",
|
||||
"privileges":[{
|
||||
"privilege_type": "r",
|
||||
"privilege": true,
|
||||
"with_grant": false
|
||||
}]
|
||||
}]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter Sequence change grantee in privileges",
|
||||
@ -282,7 +262,8 @@
|
||||
"sql_endpoint": "NODE-sequence.sql_id",
|
||||
"msql_endpoint": "NODE-sequence.msql_id",
|
||||
"data": {
|
||||
"maximum": "900"
|
||||
"owned_table": "",
|
||||
"owned_column": ""
|
||||
},
|
||||
"expected_sql_file": "alter_ownedby_remove.sql",
|
||||
"expected_msql_file": "alter_ownedby_remove_msql.sql"
|
||||
|
@ -46,7 +46,7 @@ CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE{% if add_not_exists
|
||||
{% if data.columns and data.columns|length > 0 %}
|
||||
{% for c in data.columns %}
|
||||
{% if c.name and c.cltype %}
|
||||
{% if c.inheritedfromtable %}-- Inherited from table {{c.inheritedfromtable}}: {% elif c.inheritedfromtype %}-- Inherited from type {{c.inheritedfromtype}}: {% endif %}{{conn|qtIdent(c.name)}} {% if is_sql %}{{c.displaytypname}}{% else %}{{ GET_TYPE.CREATE_TYPE_SQL(conn, c.cltype, c.attlen, c.attprecision, c.hasSqrBracket) }}{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.attnotnull %} NOT NULL{% endif %}{% if c.defval is defined and c.defval is not none and c.defval != '' %} DEFAULT {{c.defval}}{% endif %}
|
||||
{% if c.inheritedfromtable %}-- Inherited from table {{c.inheritedfromtable}}: {% elif c.inheritedfromtype %}-- Inherited from type {{c.inheritedfromtype}}: {% endif %}{{conn|qtIdent(c.name)}} {% if is_sql %}{{c.displaytypname}}{% else %}{{ GET_TYPE.CREATE_TYPE_SQL(conn, c.cltype, c.attlen, c.attprecision, c.hasSqrBracket) }}{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.attnotnull %} NOT NULL{% endif %}
|
||||
{% if c.colconstype == 'i' and c.attidentity and c.attidentity != '' %}
|
||||
{% if c.attidentity == 'a' %} GENERATED ALWAYS AS IDENTITY{% elif c.attidentity == 'd' %} GENERATED BY DEFAULT AS IDENTITY{% endif %}
|
||||
{% if c.seqincrement or c.seqcycle or c.seqincrement or c.seqstart or c.seqmin or c.seqmax or c.seqcache %} ( {% endif %}
|
||||
@ -158,6 +158,12 @@ COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}}
|
||||
{#===========================================#}
|
||||
{% if data.columns and data.columns|length > 0 %}
|
||||
{% for c in data.columns %}
|
||||
{### Alter SQL for adding sequence to column ###}
|
||||
{% if c.defval is defined and c.defval is not none and c.defval != '' %}
|
||||
|
||||
ALTER TABLE IF EXISTS ONLY {{conn|qtIdent(data.schema, data.name)}}
|
||||
ALTER COLUMN {{conn|qtIdent(c.name)}} SET DEFAULT {{c.defval}};
|
||||
{% endif %}
|
||||
{% if c.description %}
|
||||
|
||||
COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.name, c.name)}}
|
||||
|
@ -52,7 +52,7 @@ CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE{% if add_not_exists
|
||||
{% if data.columns and data.columns|length > 0 %}
|
||||
{% for c in data.columns %}
|
||||
{% if c.name and c.cltype %}
|
||||
{% if c.inheritedfromtable %}-- Inherited from table {{c.inheritedfromtable}}: {% elif c.inheritedfromtype %}-- Inherited from type {{c.inheritedfromtype}}: {% endif %}{{conn|qtIdent(c.name)}} {% if is_sql %}{{c.displaytypname}}{% else %}{{ GET_TYPE.CREATE_TYPE_SQL(conn, c.cltype, c.attlen, c.attprecision, c.hasSqrBracket) }}{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.attnotnull %} NOT NULL{% endif %}{% if c.defval is defined and c.defval is not none and c.defval != '' and c.colconstype != 'g' %} DEFAULT {{c.defval}}{% endif %}
|
||||
{% if c.inheritedfromtable %}-- Inherited from table {{c.inheritedfromtable}}: {% elif c.inheritedfromtype %}-- Inherited from type {{c.inheritedfromtype}}: {% endif %}{{conn|qtIdent(c.name)}} {% if is_sql %}{{c.displaytypname}}{% else %}{{ GET_TYPE.CREATE_TYPE_SQL(conn, c.cltype, c.attlen, c.attprecision, c.hasSqrBracket) }}{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.attnotnull %} NOT NULL{% endif %}
|
||||
{% if c.colconstype == 'i' and c.attidentity and c.attidentity != '' %}
|
||||
{% if c.attidentity == 'a' %} GENERATED ALWAYS AS IDENTITY{% elif c.attidentity == 'd' %} GENERATED BY DEFAULT AS IDENTITY{% endif %}
|
||||
{% if c.seqincrement or c.seqcycle or c.seqincrement or c.seqstart or c.seqmin or c.seqmax or c.seqcache %} ( {% endif %}
|
||||
@ -184,6 +184,12 @@ COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}}
|
||||
{#===========================================#}
|
||||
{% if data.columns and data.columns|length > 0 %}
|
||||
{% for c in data.columns %}
|
||||
{### Alter SQL for adding sequence to column ###}
|
||||
{% if c.defval is defined and c.defval is not none and c.defval != '' and c.colconstype != 'g' %}
|
||||
|
||||
ALTER TABLE IF EXISTS ONLY {{conn|qtIdent(data.schema, data.name)}}
|
||||
ALTER COLUMN {{conn|qtIdent(c.name)}} SET DEFAULT {{c.defval}};
|
||||
{% endif %}
|
||||
{% if c.description %}
|
||||
|
||||
COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.name, c.name)}}
|
||||
|
@ -54,7 +54,7 @@ CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE{% if add_not_exists
|
||||
{% if data.columns and data.columns|length > 0 %}
|
||||
{% for c in data.columns %}
|
||||
{% if c.name and c.cltype %}
|
||||
{% if c.inheritedfromtable %}-- Inherited from table {{c.inheritedfromtable}}: {% elif c.inheritedfromtype %}-- Inherited from type {{c.inheritedfromtype}}: {% endif %}{{conn|qtIdent(c.name)}} {% if is_sql %}{{c.displaytypname}}{% else %}{{ GET_TYPE.CREATE_TYPE_SQL(conn, c.cltype, c.attlen, c.attprecision, c.hasSqrBracket) }}{% endif %}{% if c.attcompression is defined and c.attcompression is not none and c.attcompression != '' %} COMPRESSION {{c.attcompression}}{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.attnotnull %} NOT NULL{% endif %}{% if c.defval is defined and c.defval is not none and c.defval != '' and c.colconstype != 'g' %} DEFAULT {{c.defval}}{% endif %}
|
||||
{% if c.inheritedfromtable %}-- Inherited from table {{c.inheritedfromtable}}: {% elif c.inheritedfromtype %}-- Inherited from type {{c.inheritedfromtype}}: {% endif %}{{conn|qtIdent(c.name)}} {% if is_sql %}{{c.displaytypname}}{% else %}{{ GET_TYPE.CREATE_TYPE_SQL(conn, c.cltype, c.attlen, c.attprecision, c.hasSqrBracket) }}{% endif %}{% if c.attcompression is defined and c.attcompression is not none and c.attcompression != '' %} COMPRESSION {{c.attcompression}}{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.attnotnull %} NOT NULL{% endif %}
|
||||
{% if c.colconstype == 'i' and c.attidentity and c.attidentity != '' %}
|
||||
{% if c.attidentity == 'a' %} GENERATED ALWAYS AS IDENTITY{% elif c.attidentity == 'd' %} GENERATED BY DEFAULT AS IDENTITY{% endif %}
|
||||
{% if c.seqincrement or c.seqcycle or c.seqincrement or c.seqstart or c.seqmin or c.seqmax or c.seqcache %} ( {% endif %}
|
||||
@ -186,6 +186,12 @@ COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}}
|
||||
{#===========================================#}
|
||||
{% if data.columns and data.columns|length > 0 %}
|
||||
{% for c in data.columns %}
|
||||
{### Alter SQL for adding sequence to column ###}
|
||||
{% if c.defval is defined and c.defval is not none and c.defval != '' and c.colconstype != 'g' %}
|
||||
|
||||
ALTER TABLE IF EXISTS ONLY {{conn|qtIdent(data.schema, data.name)}}
|
||||
ALTER COLUMN {{conn|qtIdent(c.name)}} SET DEFAULT {{c.defval}};
|
||||
{% endif %}
|
||||
{% if c.description %}
|
||||
|
||||
COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.name, c.name)}}
|
||||
|
@ -54,7 +54,7 @@ CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE{% if add_not_exists
|
||||
{% if data.columns and data.columns|length > 0 %}
|
||||
{% for c in data.columns %}
|
||||
{% if c.name and c.cltype %}
|
||||
{% if c.inheritedfromtable %}-- Inherited from table {{c.inheritedfromtable}}: {% elif c.inheritedfromtype %}-- Inherited from type {{c.inheritedfromtype}}: {% endif %}{{conn|qtIdent(c.name)}} {% if is_sql %}{{c.displaytypname}}{% else %}{{ GET_TYPE.CREATE_TYPE_SQL(conn, c.cltype, c.attlen, c.attprecision, c.hasSqrBracket) }}{% endif %}{%if c.attstorage is defined and c.attstorage != c.defaultstorage%} STORAGE {%if c.attstorage == 'p' %}PLAIN{% elif c.attstorage == 'm'%}MAIN{% elif c.attstorage == 'e'%}EXTERNAL{% elif c.attstorage == 'x'%}EXTENDED{% elif c.attstorage == 'd'%}DEFAULT{% endif %}{% endif %}{% if c.attcompression is defined and c.attcompression is not none and c.attcompression != '' %} COMPRESSION {{c.attcompression}}{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.attnotnull %} NOT NULL{% endif %}{% if c.defval is defined and c.defval is not none and c.defval != '' and c.colconstype != 'g' %} DEFAULT {{c.defval}}{% endif %}
|
||||
{% if c.inheritedfromtable %}-- Inherited from table {{c.inheritedfromtable}}: {% elif c.inheritedfromtype %}-- Inherited from type {{c.inheritedfromtype}}: {% endif %}{{conn|qtIdent(c.name)}} {% if is_sql %}{{c.displaytypname}}{% else %}{{ GET_TYPE.CREATE_TYPE_SQL(conn, c.cltype, c.attlen, c.attprecision, c.hasSqrBracket) }}{% endif %}{%if c.attstorage is defined and c.attstorage != c.defaultstorage%} STORAGE {%if c.attstorage == 'p' %}PLAIN{% elif c.attstorage == 'm'%}MAIN{% elif c.attstorage == 'e'%}EXTERNAL{% elif c.attstorage == 'x'%}EXTENDED{% elif c.attstorage == 'd'%}DEFAULT{% endif %}{% endif %}{% if c.attcompression is defined and c.attcompression is not none and c.attcompression != '' %} COMPRESSION {{c.attcompression}}{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.attnotnull %} NOT NULL{% endif %}
|
||||
{% if c.colconstype == 'i' and c.attidentity and c.attidentity != '' %}
|
||||
{% if c.attidentity == 'a' %} GENERATED ALWAYS AS IDENTITY{% elif c.attidentity == 'd' %} GENERATED BY DEFAULT AS IDENTITY{% endif %}
|
||||
{% if c.seqincrement or c.seqcycle or c.seqincrement or c.seqstart or c.seqmin or c.seqmax or c.seqcache %} ( {% endif %}
|
||||
@ -186,6 +186,12 @@ COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}}
|
||||
{#===========================================#}
|
||||
{% if data.columns and data.columns|length > 0 %}
|
||||
{% for c in data.columns %}
|
||||
{### Alter SQL for adding sequence to column ###}
|
||||
{% if c.defval is defined and c.defval is not none and c.defval != '' and c.colconstype != 'g' %}
|
||||
|
||||
ALTER TABLE IF EXISTS ONLY {{conn|qtIdent(data.schema, data.name)}}
|
||||
ALTER COLUMN {{conn|qtIdent(c.name)}} SET DEFAULT {{c.defval}};
|
||||
{% endif %}
|
||||
{% if c.description %}
|
||||
|
||||
COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.name, c.name)}}
|
||||
|
@ -46,7 +46,7 @@ CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE{% if add_not_exists
|
||||
{% if data.columns and data.columns|length > 0 %}
|
||||
{% for c in data.columns %}
|
||||
{% if c.name and c.cltype %}
|
||||
{% if c.inheritedfromtable %}-- Inherited from table {{c.inheritedfromtable}}: {% elif c.inheritedfromtype %}-- Inherited from type {{c.inheritedfromtype}}: {% endif %}{{conn|qtIdent(c.name)}} {% if is_sql %}{{c.displaytypname}}{% else %}{{ GET_TYPE.CREATE_TYPE_SQL(conn, c.cltype, c.attlen, c.attprecision, c.hasSqrBracket) }}{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.attnotnull %} NOT NULL{% endif %}{% if c.defval is defined and c.defval is not none and c.defval != '' %} DEFAULT {{c.defval}}{% endif %}
|
||||
{% if c.inheritedfromtable %}-- Inherited from table {{c.inheritedfromtable}}: {% elif c.inheritedfromtype %}-- Inherited from type {{c.inheritedfromtype}}: {% endif %}{{conn|qtIdent(c.name)}} {% if is_sql %}{{c.displaytypname}}{% else %}{{ GET_TYPE.CREATE_TYPE_SQL(conn, c.cltype, c.attlen, c.attprecision, c.hasSqrBracket) }}{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.attnotnull %} NOT NULL{% endif %}
|
||||
{% if c.colconstype == 'i' and c.attidentity and c.attidentity != '' %}
|
||||
{% if c.attidentity == 'a' %} GENERATED ALWAYS AS IDENTITY{% elif c.attidentity == 'd' %} GENERATED BY DEFAULT AS IDENTITY{% endif %}
|
||||
{% if c.seqincrement or c.seqcycle or c.seqincrement or c.seqstart or c.seqmin or c.seqmax or c.seqcache %} ( {% endif %}
|
||||
@ -157,6 +157,12 @@ COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}}
|
||||
{#===========================================#}
|
||||
{% if data.columns and data.columns|length > 0 %}
|
||||
{% for c in data.columns %}
|
||||
{### Alter SQL for adding sequence to column ###}
|
||||
{% if c.defval is defined and c.defval is not none and c.defval != '' %}
|
||||
|
||||
ALTER TABLE IF EXISTS ONLY {{conn|qtIdent(data.schema, data.name)}}
|
||||
ALTER COLUMN {{conn|qtIdent(c.name)}} SET DEFAULT {{c.defval}};
|
||||
{% endif %}
|
||||
{% if c.description %}
|
||||
|
||||
COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.name, c.name)}}
|
||||
|
Loading…
Reference in New Issue
Block a user