-- { "one_file": true }
{% for t in tables %}
{{ t.table_name }}
{{ "=" * len(t.table_name)}}
{% if t.comment %}Description: {{ t.comment }}{% endif %}
{% if t.primary_key %}Primary Key(s): {{ ", ".join(t.primary_key) }}{% endif %}
{% if t.unique %}
Unique Constraints
------------------{% for u in t.unique %}
*{% if u.name %} {{ u.name }} -{% endif %} {{ ", ".join(u.references) }}{% endfor %}{%- endif -%}
{% if t.foreign_keys %}
Foreign Keys
------------
{% for fk in t.foreign_keys %}*{% if fk.name %} {{ fk.name }} -{% endif %} {{ fk.fk }} => {{ fk.target_table }}.{{ fk.target_col }}{% if
fk.on_delete or fk.on_update %} ({% if fk.on_delete %}ON DELETE {{ fk.on_delete }}{% endif %}{{ " ," if fk.on_delete and fk.on_update or "" }}{% if fk.on_update %}ON UPDATE {{ fk.on_update }}{% endif %}){% endif %}
{% endfor %}{% endif %}
Columns
-------{% for c in t.columns.values() %}
{{ c.name }}{{ "*" if c.name in t.primary_key }} : {{ c.type }}{{ ' (Default: '+c.default+') ' if c.default }}{% if c.comment %} - {{ unquote(c.comment, True) }}{% endif %}{% endfor %}
{% endfor %}