Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/scripts/create-sample-db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
# Create a sample SQLite database with the hadiscover schema
# Usage: create-sample-db.sh <output-path>
# The database file is created using the SQLAlchemy models from the backend.

set -e

OUTPUT_PATH="${1:?Usage: create-sample-db.sh <output-path>}"

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}"
61 changes: 61 additions & 0 deletions .github/workflows/schema-diagram.yml
Original file line number Diff line number Diff line change
@@ -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
Loading