This commit is contained in:
yumoqing 2020-05-11 12:13:36 +08:00
parent 94bf65620f
commit 777b15e5f8
4 changed files with 9 additions and 15 deletions

View File

@ -31,11 +31,9 @@ NOT NULL
{%- endif -%}
{% endmacro %}
{% macro primary() %}
{% if len(','.join(summary[0].primary))>0 %}
,primary key({{','.join(summary[0].primary)}})
{% endif %}
,primary key({{summary[0].primary}})
{% endmacro %}
drop table {{summary[0].name}};
drop table if exists {{summary[0].name}};
CREATE TABLE {{summary[0].name}}
(
{% for field in fields %}
@ -52,4 +50,4 @@ default charset=utf8
CREATE {% if v.value.idxtype=='unique' %}UNIQUE{% endif %} INDEX {{summary[0].name}}_{{v.name}} ON {{summary[0].name}}({{",".join(v.value.fields)}});
{% endif %}
{%- endfor -%}
"""
"""

View File

@ -25,9 +25,7 @@ NOT NULL
{%- endif -%}
{% endmacro %}
{% macro primary() %}
{% if len(','.join(summary[0].primary))>0 %}
,primary key({{','.join(summary[0].primary)}})
{% endif %}
,primary key({{summary[0].primary}})
{% endmacro %}
drop table {{summary[0].name}};
CREATE TABLE {{summary[0].name}}
@ -46,4 +44,4 @@ COMMENT ON TABLE {{summary[0].name}} IS '{{summary[0].title}}';
{% for field in fields %}
COMMENT ON COLUMN {{summary[0].name}}.{{field.name}} is '{{field.title}}';
{% endfor %}
"""
"""

View File

@ -23,7 +23,7 @@ NOT NULL
{%- endif -%}
{% endmacro %}
{% macro primary() %}
primary key({{','.join(summary[0].primary)}})
primary key({{summary[0].primary}})
{% endmacro %}
DROP TABLE IF EXISTS {{summary[0].name}};
CREATE TABLE {{summary[0].name}}
@ -42,4 +42,4 @@ COMMENT ON TABLE {{summary[0].name}} IS '{{summary[0].title.decode('utf8')}}';
{% for field in fields %}
COMMENT ON COLUMN {{summary[0].name}}.{{field.name}} is '{{field.title.decode('utf8')}}';
{% endfor %}
"""
"""

View File

@ -26,9 +26,7 @@ NOT NULL
{% endmacro %}
{% macro primary() %}
{% if len(','.join(summary[0].primary))>0 %}
,primary key({{','.join(summary[0].primary)}})
{% endif %}
,primary key({{summary[0].primary}})
{% endmacro %}
drop table dbo.{{summary[0].name}};
@ -48,4 +46,4 @@ EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'{{summary[0].t
{% for field in fields %}
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'{{field.title}}' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'{{summary[0].name}}', @level2type=N'COLUMN',@level2name=N'{{field.name}}'
{% endfor %}
"""
"""