From 6627ffe8b56491f92bf1cb7f180ec4e1e83a69c8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 18:55:18 +0000 Subject: [PATCH 1/6] Initial plan From 503149d12b8c5173f2761f56a1f92561b3d6ca01 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 18:58:29 +0000 Subject: [PATCH 2/6] Add GitHub Actions workflow for schema diagram generation Co-authored-by: DevSecNinja <14926452+DevSecNinja@users.noreply.github.com> --- .github/scripts/create-sample-db.sh | 49 ++++++++++++++++++++++ .github/workflows/schema-diagram.yml | 63 ++++++++++++++++++++++++++++ 2 files changed, 112 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..0f13d09 --- /dev/null +++ b/.github/scripts/create-sample-db.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# Create a sample SQLite database from the hadiscover models for schema diagram generation + +set -e + +echo "Creating sample database from models..." + +# Get the script directory and project root +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" +BACKEND_DIR="$PROJECT_ROOT/backend" + +# Change to backend directory +cd "$BACKEND_DIR" + +# Activate virtual environment if it exists, otherwise create it +if [ ! -d "venv" ]; then + echo "Creating virtual environment..." + python3 -m venv venv +fi + +source venv/bin/activate + +# Install dependencies +echo "Installing dependencies..." +pip install -q -r requirements.txt + +# Create a temporary Python script to generate the database +cat > /tmp/create_db.py << 'EOF' +"""Generate sample SQLite database from SQLAlchemy models.""" +from app.models.database import Base, Repository, Automation, IndexingMetadata +from sqlalchemy import create_engine +from datetime import datetime, timezone + +# Create engine and database +engine = create_engine('sqlite:///sample_schema.db') +Base.metadata.create_all(engine) + +print("Sample database created successfully at backend/sample_schema.db") +EOF + +# Set PYTHONPATH and run the script +export PYTHONPATH="$BACKEND_DIR:$PYTHONPATH" +python /tmp/create_db.py + +# Clean up +rm /tmp/create_db.py + +echo "Database creation complete." diff --git a/.github/workflows/schema-diagram.yml b/.github/workflows/schema-diagram.yml new file mode 100644 index 0000000..b8ba781 --- /dev/null +++ b/.github/workflows/schema-diagram.yml @@ -0,0 +1,63 @@ +--- +name: Generate Database Schema Diagram + +on: # yamllint disable-line rule:truthy + workflow_dispatch: null + push: + branches: + - main + paths: + - "backend/app/models/**" + - ".github/workflows/schema-diagram.yml" + - ".github/scripts/create-sample-db.sh" + +permissions: + contents: write + +jobs: + generate-schema-diagram: + name: Generate Schema Diagram + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + with: + persist-credentials: true + + - name: Setup Python + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 + with: + python-version: "3.14" + cache: "pip" + cache-dependency-path: backend/requirements.txt + + - name: Create sample database + run: .github/scripts/create-sample-db.sh + + - name: Generate schema diagram + uses: schemacrawler/SchemaCrawler-Action@9a56a3998eca72506a483f3a0de36901c93321bf # v17.6.0 + with: + entrypoint: /schemacrawler.sh + args: >- + --server=sqlite + --database=backend/sample_schema.db + --info-level=maximum + --command=schema + --output-format=png + --output-file=schema-diagram.png + + - name: Upload schema diagram + uses: actions/upload-artifact@c0d66db0b43eb92e5f6e4fc5f8f67c6d8c1e2d10 # v4 + with: + name: database-schema-diagram + path: schema-diagram.png + retention-days: 90 + + - name: Commit schema diagram to repository + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add schema-diagram.png + git diff --staged --quiet || git commit -m "Update database schema diagram [skip ci]" + git push From 4afe8c209aee41a24385e22d9910d54a68a08cc0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 18:59:36 +0000 Subject: [PATCH 3/6] Fix yamllint issues and update documentation Co-authored-by: DevSecNinja <14926452+DevSecNinja@users.noreply.github.com> --- .github/workflows/schema-diagram.yml | 23 ++++++++++++++++------- ARCHITECTURE.md | 2 ++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.github/workflows/schema-diagram.yml b/.github/workflows/schema-diagram.yml index b8ba781..9684385 100644 --- a/.github/workflows/schema-diagram.yml +++ b/.github/workflows/schema-diagram.yml @@ -1,7 +1,8 @@ --- name: Generate Database Schema Diagram -on: # yamllint disable-line rule:truthy +# yamllint disable-line rule:truthy +on: workflow_dispatch: null push: branches: @@ -21,12 +22,14 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + # v6 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with: persist-credentials: true - name: Setup Python - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 + # v6 + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 with: python-version: "3.14" cache: "pip" @@ -36,7 +39,9 @@ jobs: run: .github/scripts/create-sample-db.sh - name: Generate schema diagram - uses: schemacrawler/SchemaCrawler-Action@9a56a3998eca72506a483f3a0de36901c93321bf # v17.6.0 + # v17.6.0 + uses: >- + schemacrawler/SchemaCrawler-Action@9a56a3998eca72506a483f3a0de36901c93321bf with: entrypoint: /schemacrawler.sh args: >- @@ -48,7 +53,9 @@ jobs: --output-file=schema-diagram.png - name: Upload schema diagram - uses: actions/upload-artifact@c0d66db0b43eb92e5f6e4fc5f8f67c6d8c1e2d10 # v4 + # v4 + uses: >- + actions/upload-artifact@c0d66db0b43eb92e5f6e4fc5f8f67c6d8c1e2d10 with: name: database-schema-diagram path: schema-diagram.png @@ -56,8 +63,10 @@ jobs: - name: Commit schema diagram to repository run: | - git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.email \ + "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" git add schema-diagram.png - git diff --staged --quiet || git commit -m "Update database schema diagram [skip ci]" + git diff --staged --quiet || \ + git commit -m "Update database schema diagram [skip ci]" git push diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 9bdc9ea..e2d9e97 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -79,6 +79,8 @@ SQLite Database ←→ GitHub API ## Database Schema +A visual schema diagram is automatically generated on each push to main when models change. See the workflow artifacts or the committed `schema-diagram.png` in the repository root. + ### repositories ```sql From 52b7dc3ceda86dcf5ba2286089bff2f36a87b063 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 19:00:22 +0000 Subject: [PATCH 4/6] Remove unused imports from database creation script Co-authored-by: DevSecNinja <14926452+DevSecNinja@users.noreply.github.com> --- .github/scripts/create-sample-db.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/scripts/create-sample-db.sh b/.github/scripts/create-sample-db.sh index 0f13d09..fe0fc5e 100755 --- a/.github/scripts/create-sample-db.sh +++ b/.github/scripts/create-sample-db.sh @@ -28,9 +28,8 @@ pip install -q -r requirements.txt # Create a temporary Python script to generate the database cat > /tmp/create_db.py << 'EOF' """Generate sample SQLite database from SQLAlchemy models.""" -from app.models.database import Base, Repository, Automation, IndexingMetadata +from app.models.database import Base from sqlalchemy import create_engine -from datetime import datetime, timezone # Create engine and database engine = create_engine('sqlite:///sample_schema.db') From cd62a6eda37822f0ace17602f29e235a4d51cf07 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 19:10:47 +0000 Subject: [PATCH 5/6] Address PR feedback: remove auto-commit, reuse install script, use python Co-authored-by: DevSecNinja <14926452+DevSecNinja@users.noreply.github.com> --- .github/scripts/create-sample-db.sh | 19 +++++-------------- .github/workflows/schema-diagram.yml | 14 ++------------ ARCHITECTURE.md | 2 +- 3 files changed, 8 insertions(+), 27 deletions(-) diff --git a/.github/scripts/create-sample-db.sh b/.github/scripts/create-sample-db.sh index fe0fc5e..75f2428 100755 --- a/.github/scripts/create-sample-db.sh +++ b/.github/scripts/create-sample-db.sh @@ -10,20 +10,10 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" BACKEND_DIR="$PROJECT_ROOT/backend" -# Change to backend directory -cd "$BACKEND_DIR" - -# Activate virtual environment if it exists, otherwise create it -if [ ! -d "venv" ]; then - echo "Creating virtual environment..." - python3 -m venv venv -fi - -source venv/bin/activate - -# Install dependencies -echo "Installing dependencies..." -pip install -q -r requirements.txt +# Install backend dependencies using the shared script +echo "Installing backend dependencies..." +cd "$PROJECT_ROOT" +.github/scripts/install-backend-deps.sh # Create a temporary Python script to generate the database cat > /tmp/create_db.py << 'EOF' @@ -39,6 +29,7 @@ print("Sample database created successfully at backend/sample_schema.db") EOF # Set PYTHONPATH and run the script +cd "$BACKEND_DIR" export PYTHONPATH="$BACKEND_DIR:$PYTHONPATH" python /tmp/create_db.py diff --git a/.github/workflows/schema-diagram.yml b/.github/workflows/schema-diagram.yml index 9684385..aa164b3 100644 --- a/.github/workflows/schema-diagram.yml +++ b/.github/workflows/schema-diagram.yml @@ -13,7 +13,7 @@ on: - ".github/scripts/create-sample-db.sh" permissions: - contents: write + contents: read jobs: generate-schema-diagram: @@ -25,7 +25,7 @@ jobs: # v6 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with: - persist-credentials: true + persist-credentials: false - name: Setup Python # v6 @@ -60,13 +60,3 @@ jobs: name: database-schema-diagram path: schema-diagram.png retention-days: 90 - - - name: Commit schema diagram to repository - run: | - git config --local user.email \ - "github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - git add schema-diagram.png - git diff --staged --quiet || \ - git commit -m "Update database schema diagram [skip ci]" - git push diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index e2d9e97..2daa4ad 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -79,7 +79,7 @@ SQLite Database ←→ GitHub API ## Database Schema -A visual schema diagram is automatically generated on each push to main when models change. See the workflow artifacts or the committed `schema-diagram.png` in the repository root. +A visual schema diagram is automatically generated on each push to main when models change. Download it from the workflow artifacts at [Actions > Generate Database Schema Diagram](../../actions/workflows/schema-diagram.yml). ### repositories From cb037406ae7d6fcca771d786ac803bd725d56fc6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 19:17:04 +0000 Subject: [PATCH 6/6] Fix SchemaCrawler-Action reference to use tag instead of commit SHA Co-authored-by: DevSecNinja <14926452+DevSecNinja@users.noreply.github.com> --- .github/workflows/schema-diagram.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/schema-diagram.yml b/.github/workflows/schema-diagram.yml index aa164b3..cc2dee2 100644 --- a/.github/workflows/schema-diagram.yml +++ b/.github/workflows/schema-diagram.yml @@ -40,8 +40,7 @@ jobs: - name: Generate schema diagram # v17.6.0 - uses: >- - schemacrawler/SchemaCrawler-Action@9a56a3998eca72506a483f3a0de36901c93321bf + uses: schemacrawler/SchemaCrawler-Action@v17.6.0 with: entrypoint: /schemacrawler.sh args: >-