{% if group_list | length > 1 -%}

{{config | get(key="title", default="") }} テーブル定義書

{% if config.author -%} {% endif -%}
作成者 {{config.author}}作成日 {{date | date(format="%x", locale=locale)}}
{% for group in group_list -%} {% endfor -%}

モデルグループ一覧

No. モデルグループ
{{loop.index}} {{group.group_def.title}}
{% if history | length > 0 -%}
{% for row in history -%} {% set description = row.description | history_description( AddTable='テーブル追加 {T}', DropTable='テーブル削除 {T}', AddColumn='カラム追加 {T} ({C})', ChangeColumn='カラム変更 {T} ({C})', DropColumn='カラム削除 {T} ({C})', ChangePrimary='主キー変更 {T}', DropPrimary='主キー削除 {T}', AddIndex='インデックス追加 {T} ({C})', ChangeIndex='インデックス変更 {T} ({C})', DropIndex='インデックス削除 {T} ({C})', AddForeign='外部キー追加 {T} ({C})', ChangeForeign='外部キー変更 {T} ({C})', DropForeign='外部キー削除 {T} ({C})', ) -%} {% if description | length == 0 %}{% continue %}{% endif -%} {% endfor -%}

更新履歴

更新日 変更内容
{{row.date | date(format="%x", locale=locale)}}
{{description | safe}}
{% endif -%}
{%- endif -%} {% for group in group_list -%}
{% if group_list | length == 1 -%}

{{config | get(key="title", default="") }} テーブル定義書

{% if config.groups | length > 1 -%} {% endif -%} {% if config.author -%} {% endif -%}
モデルグループ {{group.group_def.title}}作成者 {{config.author}}作成日 {{date | date(format="%x", locale=locale)}}
{% else -%}

{{group.group_def.title}}

{% endif -%} {% if group.models -%}
{% for model_name, model in group.models -%} {% endfor -%}

テーブル一覧

No. テーブル名
{{loop.index}} {{model_name}} {%- if model.title %} ({{model.title}}){% endif %}
{% if group.er -%}

ER図

{{group.er | safe}}
{% endif -%}
{% endif -%} {% if group.enums -%}
{% for name, enum in group.enums -%} {% endfor -%}

列挙型一覧

No. 列挙型名
{{loop.index}} {{name}} {%- if enum.title %} ({{enum.title}}){% endif %}
{% endif -%}
{% if group.models -%} {% for model_name, model in group.models -%}

{{loop.index}}. {{model_name}}{% if model.title %} ({{model.title}}){% endif %}

実テーブル名: {{model.table_name}}

{% if model.comment -%}
{{model.comment}}
{% endif -%}
{% for name, column in model.columns -%} {% endfor -%}
No. カラム名 データ型 Null 長さ 備考
{{loop.index}} {{column | get(key="rename", default=name)}} {% if column.signed %}signed {% endif %}{{column.type}} {% if not column.not_null %}Y{% endif %} {%- if column.length %}{{column.length}}{% endif %} {%- if column.precision %}{{column.precision}}{% endif %} {%- if column.scale %},{{column.scale}}{% endif %} {% if column.primary %}Y{% endif %} {%- if column.title %}

{{column.title}}

{% endif %} {%- if column.enum_values -%}

{% for enum in column.enum_values -%} {{enum.value}}:{{enum | get(key="title", default=enum.name) }} {%- if enum.comment %} ({{enum.comment}}){% endif %} {%- if not loop.last %}
{% endif %} {%- endfor %}

{%- endif -%} {%- if column.db_enum_values %}

{% for enum in column.db_enum_values -%}{{enum.name}} {%- if enum.title %}:{{enum.title}}{% endif %} {%- if enum.comment %} ({{enum.comment}}){% endif %} {%- if not loop.last %}
{% endif %} {%- endfor %}

{%- endif -%} {%- if column.enum_class %}{{column.enum_class}} {%- endif -%} {%- if column.comment %}
{{column.comment}}
{% endif -%}

データ型に signed の指定がない場合、 double, decimal 等も含めすべての数値型は unsigned。

{% if model.indexes -%}
{% for name, index in model.indexes -%} {% endfor -%}

インデックス

No. タイプ カラム
{{loop.index}} {%- if index %}{{index | get(key="type", default="INDEX") | upper}} {%- else %}INDEX{% endif %} {%- if index and index.fields %}{% for name, field in index.fields -%}{{name}} {%- if field and field.length %}({{field.length}}){% endif %} {%- if not loop.last %}, {% endif %} {%- endfor %}{% else %}{{name}}{% endif %}
{% endif -%} {% if model.relations -%}
{% for name, relation in model.relations -%} {% set type = relation | get(key="type", default="one") %} {% endfor -%}

リレーション

No. 名前 タイプ カラム 結合先 結合カラム 削除時
{{loop.index}} {{relation | get(key="title", default=name)}} {% if type == "one_to_one" %}ONE{% else %}{{type | upper}}{% endif %} {%- if relation.local %}{{relation.local}}{% else %} {%- if type == "many" or type == "one_to_one" %}-{% else %}{{name}}_id{% endif %} {%- endif %} {{relation.model | split(pat="::") | last}} {%- if relation.foreign %}{{relation.foreign}}{% else %} {%- if type == "many" %}{{model_name}}_id{% else %}-{% endif %} {% endif %} {{relation | get(key="on_delete", default="")}}

カラムの - は主キー。{%- if config.ignore_foreign_key %}実際にはデータベースに外部キー制約は設定しない。{% endif -%}

{% endif -%}
{% endfor -%} {% endif -%} {% if group.enums -%}
{% for name, enum in group.enums -%}

{{loop.index}}. {{name}}{% if enum.title %} ({{enum.title}}){% endif %}

{% if enum.comment -%}
{{enum.comment}}
{% endif -%} {% for value in enum.enum_values -%} {% endfor -%}
名前 備考
{{value.value}} {{value | get(key="title", default=value.name) }} {%- if value.comment %}
{{value.comment}}
{% endif -%}
{% endfor -%}
{% endif -%} {% endfor -%}