{% load i18n %}

๐Ÿ”— {% trans "Dependencies" %}

{% trans "foreign-key order ยท safe truncate/load order ยท cycle check" %}

{% if not graph.edges %}

{% blocktrans count counter=graph.node_count %}No foreign keys among your {{ counter }} table โ€” they can be truncated or loaded in any order.{% plural %}No foreign keys among your {{ counter }} tables โ€” they can be truncated or loaded in any order.{% endblocktrans %}

{% else %} {% if graph.has_cycle %}
{% trans "Foreign-key cycle" %}

{% trans "These tables reference each other in a loop, so there is no order that satisfies every foreign key. You can't compute a safe TRUNCATE/load order until the cycle is broken (or you TRUNCATE the whole set together with CASCADE)." %}

{% for t in graph.cycle %}{{ t }}{% if not forloop.last %}โ†’{% endif %}{% endfor %}

{% else %}
{% if connection.kind != 'mysql' %} {% endif %}

{% trans "Delete/truncate top to bottom: each table comes before the tables it points at, so you never orphan a referencing row." %}

{% trans "Insert/restore top to bottom: each referenced table is created before the tables that point at it." %}

    {% for t in graph.order %}
  1. {{ forloop.counter }} {{ t }}
  2. {% endfor %}
    {% for t in graph.load_order %}
  1. {{ forloop.counter }} {{ t }}
  2. {% endfor %}
{% endif %} {% if graph.self_refs %}

{% trans "Self-referential โ€” these tables have a foreign key pointing at themselves. Their position in the order is fine, but a plain TRUNCATE needs CASCADE (or delete leaf rows first):" %}

{% for t in graph.self_refs %}{{ t }}{% endfor %}

{% endif %}
{% trans "Foreign keys" %} {{ graph.edge_count }} edge{{ graph.edge_count|pluralize }}
{% for e in graph.edges %} {% endfor %}
{% trans "Child (references)" %} {% trans "Parent (referenced)" %} {% trans "Columns" %} {% trans "Constraint" %}
{{ e.child }} {% if e.self_ref %}โ†ป {{ e.parent }}{% else %}{{ e.parent }}{% endif %} {{ e.columns }} {{ e.constraint }}
{% endif %}