Merged in feature/updateddbdiagram (pull request #75)

Updated DB Diagram

* update
This commit is contained in:
Michael McGuinness
2025-02-24 18:18:23 +00:00
parent 08d2296717
commit a49084ebce
3 changed files with 164 additions and 93 deletions
+1
View File
@@ -0,0 +1 @@
diagram.png
+5 -93
View File
@@ -1,101 +1,13 @@
# Database schema
To view this diagrem live in vscode use the https://marketplace.visualstudio.com/items?itemName=bierner.markdown-mermaid extension.
To view this diagram live in vscode use the `https://marketplace.visualstudio.com/items?itemName=bierner.markdown-mermaid` extension.
You can also edit live with https://mermaid.live
You can also edit live with `https://mermaid.live`
This diagram should be updated manually when there are changes to the database schema.
To generate the diagram directly use the following command:
To generate the diagram directly use the following command, in the root directory:
```bash
docker run --rm -v $(pwd):/data minlag/mermaid-cli -i /data/diagram.mmd -o /data/output.png -w 1024 -H 768
```
```mermaid
erDiagram
clients ||--o{ jobs : has
jobs ||--o{ documents : has
jobs ||--|| collectors : has
documents ||--o{ results : has
queries ||--o{ results : has
queries ||--o{ requiredQueries : has
queries ||--o{ queryConfigs : has
collectors ||--o{ collectorQueries : has
collectors ||--o{ collectorCodeVersions : has
queries ||--o{ collectorQueries : references
clients {
uuid id PK
text name UK
boolean canSync
}
jobs {
uuid id PK
uuid clientId FK
boolean canSync
}
documents {
uuid id PK
uuid jobId FK
}
collectors {
uuid id PK
uuid jobId FK
int latestVersion
int activeVersion
}
collectorCodeVersions {
uuid id PK
uuid collectorId FK
int minCleanVersion
int minTextVersion
int addedVersion
int removedVersion
}
queries {
uuid id PK
int latestVersion
int activeVersion
queryType type
}
requiredQueries {
uuid id PK
uuid queryId FK
uuid requiredQueryId FK
int addedVersion
int removedVersion
}
queryConfigs {
uuid id PK
uuid queryId FK
jsonb config
int addedVersion
int removedVersion
}
collectorQueries {
uuid id PK
uuid collectorId FK
varchar name
uuid queryId FK
int addedVersion
int removedVersion
}
results {
uuid id PK
uuid queryId FK
uuid documentId FK
text value
int cleanVersion
int textVersion
int queryVersion
}
docker run --rm -u $(id -u):$(id -g) -v $(pwd)/database:/data minlag/mermaid-cli:latest -i /data/diagram.mmd -o /data/diagram.png -w 2000 -H 2000
```
+158
View File
@@ -0,0 +1,158 @@
erDiagram
clients ||--o{ clientCanSync : "has"
clients ||--o{ jobs : "has"
jobs ||--o{ jobCanSync : "has"
jobs ||--o{ documents : "contains"
jobs ||--o{ collectorVersions : "has"
jobs ||--o{ collectorActiveVersions : "has current"
jobs ||--o{ collectorMinCleanVersions : "has"
jobs ||--o{ collectorMinTextVersions : "has"
jobs ||--o{ collectorQueries : "maps to"
documents ||--o{ documentEntries : "has"
documents ||--o{ documentCleans : "has clean version"
documentCleans ||--o{ documentTextExtractions : "has text extraction"
documentTextExtractions ||--o{ results : "produces"
queries ||--o{ queryVersions : "has"
queries ||--o{ queryActiveVersions : "has current"
queries ||--o{ requiredQueries : "requires"
queries ||--o{ queryConfigs : "configured by"
queries ||--o{ collectorQueries : "used in"
queries ||--o{ results : "generates"
results ||--o{ resultDependencies : "depends on"
clients {
uuid id PK
TEXT name
}
clientCanSync {
uuid id PK
uuid clientId FK
boolean canSync
}
jobs {
uuid id PK
uuid clientId FK
}
jobCanSync {
uuid id PK
uuid jobId FK
boolean canSync
}
documents {
uuid id PK
uuid jobId FK
text hash
}
documentEntries {
uuid id PK
uuid documentId FK
text bucket
text key
}
documentCleans {
uuid id PK
uuid documentId FK
int version
text bucket
text key
}
documentTextExtractions {
uuid id PK
uuid cleanEntryId FK
int version
text bucket
text key
}
queries {
uuid id PK
queryType type
}
queryVersions {
uuid queryId FK
int id
timestamp addedAt
}
queryActiveVersions {
uuid id PK
uuid queryId FK
int versionId FK
}
requiredQueries {
uuid id PK
uuid queryId FK
uuid requiredQueryId FK
int addedVersion FK
int removedVersion FK
}
queryConfigs {
uuid id PK
uuid queryId FK
jsonb config
int addedVersion FK
int removedVersion FK
}
collectorVersions {
uuid jobId FK
int id
timestamp addedAt
}
collectorActiveVersions {
uuid id PK
uuid jobId FK
int versionId FK
}
collectorMinCleanVersions {
uuid id PK
uuid jobId FK
int versionId
int addedVersion FK
int removedVersion FK
}
collectorMinTextVersions {
uuid id PK
uuid jobId FK
int versionId
int addedVersion FK
int removedVersion FK
}
collectorQueries {
uuid id PK
uuid jobId FK
varchar name
uuid queryId FK
int addedVersion FK
int removedVersion FK
}
results {
uuid id PK
uuid textEntryId FK
uuid queryId FK
TEXT value
int queryVersion
}
resultDependencies {
uuid resultId FK
uuid requiredResultId FK
}