From 293145603641680c7d2d21d7d486473dd9e30eb0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 19:26:22 +0000 Subject: [PATCH 1/3] Initial plan From a4c55855c29e64eb8d349f3634fed6b4e692a4c9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 19:29:27 +0000 Subject: [PATCH 2/3] Add schema diagram workflow and sample DB script Create a GitHub Actions workflow that generates database schema diagrams using SchemaCrawler-Action. The workflow: - Triggers on push/PR to main when backend model files change - Supports manual dispatch - Creates a sample SQLite DB from SQLAlchemy models - Generates a schema diagram PNG via SchemaCrawler - Uploads the diagram as a workflow artifact Co-authored-by: DevSecNinja <14926452+DevSecNinja@users.noreply.github.com> --- .github/scripts/create-sample-db.sh | 22 ++++++++++ .github/workflows/schema-diagram.yml | 61 ++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100755 .github/scripts/create-sample-db.sh create mode 100644 .github/workflows/schema-diagram.yml diff --git a/.github/scripts/create-sample-db.sh b/.github/scripts/create-sample-db.sh new file mode 100755 index 0000000..9032d0e --- /dev/null +++ b/.github/scripts/create-sample-db.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# Create a sample SQLite database with the hadiscover schema +# Usage: create-sample-db.sh +# The database file is created using the SQLAlchemy models from the backend. + +set -e + +OUTPUT_PATH="${1:?Usage: create-sample-db.sh }" + +echo "Creating sample database at ${OUTPUT_PATH}..." + +DATABASE_URL="sqlite:///${OUTPUT_PATH}" python -c " +from app.models.database import Base +from sqlalchemy import create_engine +import os + +engine = create_engine(os.environ['DATABASE_URL']) +Base.metadata.create_all(bind=engine) +engine.dispose() +" + +echo "✓ Sample database created at ${OUTPUT_PATH}" diff --git a/.github/workflows/schema-diagram.yml b/.github/workflows/schema-diagram.yml new file mode 100644 index 0000000..026d3a8 --- /dev/null +++ b/.github/workflows/schema-diagram.yml @@ -0,0 +1,61 @@ +--- +name: Schema Diagram + +on: # yamllint disable-line rule:truthy + workflow_dispatch: null + push: + branches: + - main + paths: + - "backend/app/models/**" + pull_request: + branches: + - main + paths: + - "backend/app/models/**" + +permissions: + contents: read + +jobs: + schema-diagram: + name: Generate Schema Diagram + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + with: + persist-credentials: false + + - name: Setup Python + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 + with: + python-version: "3.14" + cache: "pip" + cache-dependency-path: backend/requirements.txt + + - name: Install backend dependencies + run: .github/scripts/install-backend-deps.sh + + - name: Create sample database + run: .github/scripts/create-sample-db.sh "${{ github.workspace }}/hadiscover.db" + working-directory: backend + + - name: Generate schema diagram + uses: schemacrawler/SchemaCrawler-Action@v17.6.0 + with: + entrypoint: /schemacrawler.sh + args: > + --server=sqlite + --database=hadiscover.db + --info-level=standard + --command=schema + --output-file schema-diagram.png + --log-level CONFIG + + - name: Upload schema diagram + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: schema-diagram + path: schema-diagram.png From 581e4a1d021c3d655c0bb4a524c8cb73fe04ee6b Mon Sep 17 00:00:00 2001 From: Jean-Paul van Ravensberg <14926452+DevSecNinja@users.noreply.github.com> Date: Sat, 7 Feb 2026 20:40:25 +0100 Subject: [PATCH 3/3] Update schema-diagram.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/schema-diagram.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/schema-diagram.yml b/.github/workflows/schema-diagram.yml index 026d3a8..01cc051 100644 --- a/.github/workflows/schema-diagram.yml +++ b/.github/workflows/schema-diagram.yml @@ -39,7 +39,7 @@ jobs: run: .github/scripts/install-backend-deps.sh - name: Create sample database - run: .github/scripts/create-sample-db.sh "${{ github.workspace }}/hadiscover.db" + run: ../.github/scripts/create-sample-db.sh "${{ github.workspace }}/hadiscover.db" working-directory: backend - name: Generate schema diagram