{# table_schema.py.jinja2
   Generation unit: table
   Renders one SQL CREATE TABLE block.
   Expects: {{ table }} dict from helpers.prepare_tables()
   Note: included inside an executescript() string; indent 12 spaces.
#}
            CREATE TABLE IF NOT EXISTS {{ table.name }} (
{% for col in table.columns %}
                {{ col.name }} {{ col.sqlite_type }}{{ col.constraints }}{% if not loop.last or table.foreign_keys %},{% endif %}

{% endfor %}
{% for fk in table.foreign_keys %}
                FOREIGN KEY ({{ fk.col }}) REFERENCES {{ fk.ref_table }}({{ fk.ref_col }}){% if not loop.last %},{% endif %}

{% endfor %}
            )