This commit is contained in:
yumoqing 2023-04-19 15:22:36 +08:00
parent 246ebad120
commit 7b99ce052c

View File

@ -25,6 +25,11 @@ longblob
{{type}} {{type}}
{%- endif %} {%- endif %}
{%- endmacro %} {%- endmacro %}
{%- macro defaultValue(defaultv) %}
{%- if defaultv %} DEFAULT '{{defaultv}}'{%- endif -%}
{%- endmacro %}
{% macro nullStr(nullable) %} {% macro nullStr(nullable) %}
{%- if nullable=='no' -%} {%- if nullable=='no' -%}
NOT NULL NOT NULL
@ -37,7 +42,7 @@ drop table if exists {{summary[0].name}};
CREATE TABLE {{summary[0].name}} CREATE TABLE {{summary[0].name}}
( (
{% for field in fields %} {% for field in fields %}
`{{field.name}}` {{typeStr(field.type,field.length,field.dec)}} {{nullStr(field.nullable)}} {%if field.title -%} comment '{{field.title}}'{%- endif %}{%- if not loop.last -%},{%- endif -%} `{{field.name}}` {{typeStr(field.type,field.length,field.dec)}} {{nullStr(field.nullable)}} {{defaultValue(field.default)}} {%if field.title -%} comment '{{field.title}}'{%- endif %}{%- if not loop.last -%},{%- endif -%}
{% endfor %} {% endfor %}
{% if summary[0].primary and len(summary[0].primary)>0 %} {% if summary[0].primary and len(summary[0].primary)>0 %}
{{primary()}} {{primary()}}