{{ ui.icon("database") }}{{ c.name }} {% if c.allowed %}allowed{% else %}blocked{% endif %}
- Kind
- {{ c.kind_name }}
- {% if c.kind == "sqlite" %}File{% else %}Server{% endif %}
{{ c.host or "—" }}{% if c.port %}:{{ c.port }}{% endif %}
{{ c.host or "—" }}{% if c.port %}:{{ c.port }}{% endif %}{{ value }}
{%- else %}{{ value }}{% endif %}
{%- elif key == "found_in" %}{% for place in value %}{{ place }}{% if not loop.last %}{{ value }}{% else %}{{ value }}{% endif %}
{%- elif key == "objects" %}
{%- elif key == "evidence" and value %}{{ value }}
{%- elif key == "where" and value %}{{ value }}
{%- elif key == "page" %}{% if row.page %}{% else %}-{% endif %}
{%- elif value is none or value == "" or value == [] -%}-
{%- else %}{{ value }}{% endif -%}
{%- endmacro %}
{% macro post(action, confirm="", title="") -%}
hx-post="/databases/{{ action }}" hx-target="#content"{% if confirm %} hx-confirm="{{ confirm }}"{% endif %}{% if title %} data-confirm-title="{{ title }}"{% endif %}
{%- endmacro %}
The databases doctracker read from the allowed connections, as SQL organises them: servers, databases, schemas, tables and views, columns. Click a node to go into it; choose in the legend which relations to see.
{{ ui.universe_canvas(params.open or "", "/graph/universe" if has_collections else "", "" if has_collections else "No database read yet: allow a connection in Connections.") }} {% elif tab == "diagram" %}The entity-relationship diagram of the databases read and of what the project's files declare, in the levels of the tree: each table and view with its columns, the foreign keys from a column to the column it refers to, with how many rows each end may have. Click a level to open it, its title to close it; choose in the legend which relations to see, and on the bar the notation.
{% set bar_filters %} {% endset %} {% set er_actions %} {% endset %} {% call ui.view_canvas("er", er_url, params.focus or "", layouts=true, filters=bar_filters, filters_open=true, details=true, notation=true, actions=er_actions, empty="" if er_url else "No database read and no schema file yet: allow a connection in Connections.") %} project connection / file database / schema table view unconnected 3 ▸closed (click to open) {{ ui.relation_kinds(("foreign-key", "implied", "view-reads", "partition-of", "inherits", "foreign-table", "contained-in"), off=("contained-in",)) }} || one · o| zero or one · o< zero or many {% endcall %} {% elif tab == "slices" %}Slices of the schema: a few tables kept together, cut from the whole — a part of the system with a name and a text saying what it is for, its boxes placed in the Diagram as you left them. Each slice is a file in doc/slices/, versioned with the project; its tables are found where they were taken from, or by their name elsewhere. The agents read them too.
{% if not slices %}No slice yet: make one with “New slice”, or choose tables in the Diagram (Ctrl + click) and Save as slice.
{% endif %}a slice of {{ s.databases | map("replace", "db:", "") | map("replace", "origin:", "") | join(", ") or "nothing read" }}: {{ s.tables | selectattr("found") | list | length }} of {{ s.total }} tables
{% if s.text %}{{ s.text }}
{% endif %}How the project's schema evolved, from its migrations and its commits: one lane per origin (SQL files, migration sets, ORM models, dumps), each migration step at the commit that brought it, each commit that changed the origin's files; a filled dot is a migration step, a hollow one a commit, a red ring a step changed after it was created. Click a moment to see what it did; Diff compares the schema at two moments.
{% macro moment_options(chosen) -%} {% for lane in evolution.lanes %}{% endfor %} {%- endmacro %} {% set bar_filters %} {% endset %} {% set diff_row %} {% endset %} {% call ui.view_canvas("evolution", "/graph/evolution" if evolution.moments else "", "", filters=bar_filters, details=true, diff=diff_row, empty="" if evolution.moments else "No migrations nor schema files in the project yet.") %} migration step commit step changed after it was created not committed follows (branches and merges) {% endcall %}Loading…
{% endif %}Two places compared, each chosen down its trail: a file of the project (its SQL, migrations, ORM models or dump, as it ends once every step is applied) or a database read, a whole one, a schema, or one table or view. Choosing a file fills B with the database it created (by the migration tool's history table, or the configuration naming it); B can be changed to any other place, a staging database say. Two schemas or two tables of different names are compared with each other. Computed when the page opens: nothing is kept.
{% set HOW = {"history": ("by its history", "The database's own history table of this tool records these steps as applied."), "declared": ("by its configuration", "The origin's configuration, or a connection declared in its folder, names this database."), "related": ("through its migrations", "The ORM's migrations created this database: its models describe the same one.")} %} {# One side of the comparison, a form of its own: the kind of place (buttons), then one autocomplete field per level (Focus's: type a part of the name or path, ↑ ↓ and Enter, or a click), each listing what the field before it holds. A choice redraws the page; the fields under a changed one empty (web.diff_context). #} {% macro diff_side(side, label) -%} {% set boxes = diff_trails[side] %} {%- endmacro %}No profile yet: compare two places in Trails, then Save profile.
{% endif %}{{ s.names.a }} × {{ s.names.b }}{% if s.ignore %} · ignoring {{ s.ignore | join(", ") }}{% endif %}
{{ s.description }}
{% endif %}Choose A: a file of the project or a database.
{% elif not diff_b %}Nothing says which database {{ diff_a.removeprefix("origin:") }} created: choose B.
{% elif diff.error %}{{ diff.error }}
{% else %} {% set base = "/databases/diff?view=trails&a=" ~ (diff_a | urlencode) ~ "&b=" ~ (diff_b | urlencode) ~ "&show=" %}{{ t.key }}{% else %}{{ t.key }}{% endif %}
{{ t.kind }}{% if t.whole %} · only in {{ diff_names.a if diff_show == "only_a" else diff_names.b }}{% endif %}
{% if t.commits %}{{ ui.icon("database") }}Evolution{% endif %}Commits: {% for c in t.commits %}{{ c.short }}{% endfor %}
{% endif %}Nothing here: {% if diff_show == "only_a" %}{{ diff_names.b }} holds everything {{ diff_names.a }} holds{% elif diff_show == "only_b" %}{{ diff_names.a }} holds everything {{ diff_names.b }} holds{% else %}what both hold is the same{% endif %}.
{% endfor %}What in the databases' schema and in the project's migrations deserves a look: tables without a primary key, foreign keys without an index, relations only by name, destructive migration steps, and more — each rule's ? says why it matters and how to fix it. The databases read and the project's files are linted alike; the same finding in several of them is one row, Found in telling where. A finding you accept, with its reason, stays listed as accepted (the State filter shows it), kept in doc/lint/accepted.json with the project.
{# The counters of the open findings, by level and by rule: a click lists only those. #}Every object doctracker read from the allowed connections. Browse goes down the SQL tree one level at a time (servers, databases, schemas, tables and views, columns): a name goes into it, the path above goes back. Search lists every object at once. A column's title sorts by it, its filter icon filters it; the page icon opens the object's page.
{# The mode, and what goes with every request of the list: the level (Browse) or the filters above (Search), the order chosen (sort, dir). #} {% if not has_collections %}No database read yet: allow a connection in Connections.
{% else %} {% set label %}{{ listing.total }} {% if mode == "browse" %}{{ level if listing.total != 1 else level[:-1] }}{% else %}object{% if listing.total != 1 %}s{% endif %}{% endif %}{% endset %} {% call(row, key, value) ui.list_table("objects", "#objects-filter", listing, label, db_urls.objects) %} {%- if row is none -%} {%- if key == "size" %}{{ value | int | size }}{% elif key == "read" %}{{ value | local_time(seconds=True) }}{% elif key == "marks" %}{{ db_marks.get(value, value) }}{% else %}{{ value }}{% endif -%} {%- else -%} {%- set value = row[key] -%} {%- if key == "name" -%} {%- if row.down %}{{ row.name }}
{%- else %}{{ row.name }}{% endif -%}
{%- elif key == "page" -%}
{%- elif value is none or value == "" or value == [] -%}-
{%- elif key == "marks" -%}{% for mark in value %}{{ db_marks[mark] }}{% endfor %}
{%- elif key == "size" -%}{{ value | size }}
{%- elif key == "read" -%}{{ value | local_time(seconds=True) }}
{%- elif key in ("type", "default") -%}{{ value }}
{%- elif key == "where" -%}{{ value }}
{%- elif value is number -%}{{ "{:,}".format(value) }}
{%- else -%}{{ value }}{%- endif -%}
{%- endif -%}
{% endcall %}
{% endif %}
{% else %}
The databases your project declares, and those you enter. Declared ones stay blocked until you allow them; doctracker only ever reads: the session is read only where the database allows it, every transaction is rolled back, and any statement that is not a read is aborted before it is sent.
{% if error %}{{ error }}
{% endif %} {% if locked %} {# No vault on this system: the saved passwords open with a master password, typed once per start. #} {% endif %} {% if not connections %}Nothing found in the project's files. Enter a connection with “New connection”.
{% endif %}