{% load i18n %}
{% trans "foreign-key order ยท safe truncate/load order ยท cycle check" %}
{% 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 %}
{% 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 %}
{% 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." %}
{% 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 %}
| {% 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 }} |