Skip to content

Automate ER Model Generation for Database Schema in GitHub Pages #882

Open
@coderabbitai

Description

@coderabbitai

Objective

Add automated ER model generation from SQL schema to the GitHub Pages workflow.

Background

We need to automatically generate and update the ER model diagram based on:

  1. Base SQL schema (.resources/zms.sql)
  2. Applied migrations (zmsdb/migrations/)

The diagram should be automatically updated whenever new migrations are added or the base schema changes.

Technical Requirements

  1. Parse SQL schema files:
    • Base schema from .resources/zms.sql
    • Migration files from zmsdb/migrations/
  2. Generate Mermaid ER diagram showing:
    • Tables and their fields
    • Primary and foreign keys
    • Relationships between tables
    • Field types and constraints
  3. Integrate diagram generation into GitHub Pages workflow (.github/workflows/deploy-pages.yaml)
  4. Update diagram when schema changes

Implementation Steps

  1. Add SQL parsing functionality:
    • Parse CREATE TABLE statements
    • Parse ALTER TABLE statements
    • Extract relationships from foreign keys
  2. Add Mermaid diagram generation:
    • Convert parsed schema to Mermaid syntax
    • Group related tables
    • Show cardinality in relationships
  3. Integrate with GitHub Pages workflow:
    • Add new step for diagram generation
    • Configure caching for better performance
    • Set up proper file paths
  4. Add change detection:
    • Monitor schema file changes
    • Monitor migration additions
    • Trigger workflow on changes

References

Metadata

Metadata

Assignees

Labels

actionsEverything Github Actions

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions