mirror of
https://github.com/Dictionarry-Hub/schema.git
synced 2026-05-03 06:14:17 +02:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e1c2bd73d7 | |||
| 12f1e721fe | |||
| 00bca26d38 | |||
| 29557fdfe8 | |||
| 71d5dad817 |
+469
-20
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 27 KiB |
+469
-20
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 27 KiB |
@@ -0,0 +1,39 @@
|
||||
name: Generate Schema Diagram
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
paths:
|
||||
- ops/0.schema.sql
|
||||
- scripts/generate-schema-diagram.sh
|
||||
- .github/workflows/generate-schema-diagram.yml
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
generate:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install Graphviz
|
||||
run: sudo apt-get update && sudo apt-get install -y graphviz
|
||||
|
||||
- name: Generate diagram
|
||||
run: ./scripts/generate-schema-diagram.sh
|
||||
|
||||
- name: Commit updates
|
||||
run: |
|
||||
if git diff --quiet; then
|
||||
echo "No changes to commit."
|
||||
exit 0
|
||||
fi
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git add .github/image/schema.svg .github/image/schema-dark.svg README.md
|
||||
git commit -m "chore: update schema diagram"
|
||||
git push
|
||||
@@ -13,6 +13,9 @@ This repository hosts the base schema applied to all
|
||||
</picture>
|
||||
</p>
|
||||
|
||||
Diagram is auto-generated from `ops/0.schema.sql` by the
|
||||
`generate-schema-diagram` workflow. Do not edit the SVGs by hand.
|
||||
|
||||
## Documentation
|
||||
|
||||
- [Manifest Specification](docs/manifest.md) - Required manifest file format for
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE quality_group_members ADD COLUMN position INTEGER NOT NULL DEFAULT 0;
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "schema",
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.0",
|
||||
"description": "Base schema for all Profilarr Compliant Databases - defines the structural foundation that all PCDs build upon",
|
||||
"arr_types": ["radarr", "sonarr"],
|
||||
|
||||
|
||||
Executable
+61
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
schema_sql="$repo_root/ops/0.schema.sql"
|
||||
out_dir="$repo_root/.github/image"
|
||||
|
||||
tmp_dir="$(mktemp -d)"
|
||||
dot_file="$tmp_dir/schema.dot"
|
||||
|
||||
SCHEMA_SQL="$schema_sql" DOT_FILE="$dot_file" python3 - <<'PY'
|
||||
import os
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
schema_sql = Path(os.environ["SCHEMA_SQL"]).read_text(encoding="utf-8")
|
||||
|
||||
create_table_re = re.compile(r"CREATE\s+TABLE\s+([A-Za-z0-9_]+)\s*\(", re.IGNORECASE)
|
||||
references_re = re.compile(r"REFERENCES\s+([A-Za-z0-9_]+)", re.IGNORECASE)
|
||||
|
||||
tables = set(create_table_re.findall(schema_sql))
|
||||
blocks = re.split(r"CREATE\s+TABLE\s+", schema_sql, flags=re.IGNORECASE)[1:]
|
||||
|
||||
edges = set()
|
||||
for block in blocks:
|
||||
name_match = re.match(r"([A-Za-z0-9_]+)", block)
|
||||
if not name_match:
|
||||
continue
|
||||
table_name = name_match.group(1)
|
||||
for ref in references_re.findall(block):
|
||||
edges.add((table_name, ref))
|
||||
|
||||
lines = []
|
||||
lines.append("digraph schema {")
|
||||
lines.append(" rankdir=LR;")
|
||||
lines.append(" splines=true;")
|
||||
lines.append(" overlap=false;")
|
||||
lines.append("")
|
||||
for table in sorted(tables):
|
||||
lines.append(f' "{table}";')
|
||||
lines.append("")
|
||||
for src, dst in sorted(edges):
|
||||
lines.append(f' "{src}" -> "{dst}";')
|
||||
lines.append("}")
|
||||
|
||||
Path(os.environ["DOT_FILE"]).write_text("\n".join(lines) + "\n", encoding="utf-8")
|
||||
PY
|
||||
|
||||
mkdir -p "$out_dir"
|
||||
|
||||
dot -Tsvg -o "$out_dir/schema.svg" \
|
||||
-Gbgcolor="#ffffff" \
|
||||
-Nshape="box" -Nstyle="filled" -Nfillcolor="#f8f8f8" -Ncolor="#444444" -Nfontcolor="#111111" -Nfontname="Helvetica" -Nfontsize="12" \
|
||||
-Ecolor="#666666" \
|
||||
"$dot_file"
|
||||
|
||||
dot -Tsvg -o "$out_dir/schema-dark.svg" \
|
||||
-Gbgcolor="#0b0b0b" \
|
||||
-Nshape="box" -Nstyle="filled" -Nfillcolor="#1f1f1f" -Ncolor="#777777" -Nfontcolor="#f5f5f5" -Nfontname="Helvetica" -Nfontsize="12" \
|
||||
-Ecolor="#aaaaaa" \
|
||||
"$dot_file"
|
||||
Reference in New Issue
Block a user