5 Commits

Author SHA1 Message Date
Sam Chau e1c2bd73d7 feat: add position column to quality_group_members 2026-03-12 09:39:26 +10:30
Sam Chau 12f1e721fe Revert "fix: add cleanup triggers for orphaned conditions"
This reverts commit 00bca26d38.
2026-02-11 22:06:15 +10:30
Sam Chau 00bca26d38 fix: add cleanup triggers for orphaned conditions
When a regex or language is deleted, the FK cascade deletes the
condition_patterns/condition_languages row but leaves the parent
condition orphaned. These triggers clean up the parent condition.
2026-02-11 02:36:34 +10:30
github-actions[bot] 29557fdfe8 chore: update schema diagram 2026-01-29 00:54:20 +00:00
Sam Chau 71d5dad817 feat: add workflow to generate schema diagram and update README 2026-01-29 11:23:52 +10:30
7 changed files with 1043 additions and 41 deletions
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
View File
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
+3
View File
@@ -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
+1
View File
@@ -0,0 +1 @@
ALTER TABLE quality_group_members ADD COLUMN position INTEGER NOT NULL DEFAULT 0;
+1 -1
View File
@@ -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"],
+61
View File
@@ -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"