{"id":13706952,"url":"https://github.com/bcgov/SchemaSpy","last_synced_at":"2025-05-05T23:31:56.056Z","repository":{"id":55257635,"uuid":"75781972","full_name":"bcgov/SchemaSpy","owner":"bcgov","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-24T22:06:46.000Z","size":8475,"stargazers_count":8,"open_issues_count":7,"forks_count":12,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-01-24T23:18:37.532Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bcgov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-06T23:53:05.000Z","updated_at":"2025-01-24T22:06:51.000Z","dependencies_parsed_at":"2024-11-08T16:38:01.476Z","dependency_job_id":null,"html_url":"https://github.com/bcgov/SchemaSpy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcgov%2FSchemaSpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcgov%2FSchemaSpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcgov%2FSchemaSpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcgov%2FSchemaSpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bcgov","download_url":"https://codeload.github.com/bcgov/SchemaSpy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252593220,"owners_count":21773431,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T22:01:13.418Z","updated_at":"2025-05-05T23:31:55.736Z","avatar_url":"https://github.com/bcgov.png","language":"Dockerfile","funding_links":[],"categories":["Dockerfile"],"sub_categories":[],"readme":"# SchemaSpy\n\nQuickly run SchemaSpy on a Postgres, MySQL, or SQLite3 database in order\nto generate a browsable visualization of the tables, columns, and relationships.\n\nBased on `openjdk:jre-alpine` the resulting image generates the database documentation using SchemaSpy and serves the resulting html using Caddy, and is compatible with OpenShift.\n\nThe open source SchemaSpy project is located here: https://github.com/schemaspy/schemaspy\n\nThe open source Caddy project is located here; https://github.com/mholt/caddy\n\n## Configuration\n\nConfiguration is performed using environment varables.\n\n| Name | Description | Example |\n| ---- | ------- | ------- |\n| DATABASE_TYPE | The database type being documented.  Defaults to `pgsql`. | One of `mysql`, `pgsql`, or `sqlite`.  Other database types are supported by SchemaSpy, but their JDBC connector libraries are not currently included in the image. |\n| DATABASE_NAME | The name of the database to document. | MyDatabase |\n| DATABASE_HOST | The hostname of the server |  postgresql |\n| DATABASE_SCHEMA | OPTIONAL - The schema in the database to document.  Defaults to `public`. | my_schema |\n| DATABASE_CATALOG | OPTIONAL - The catalog in the database to document.  With some databases this is used to define the name of the database. | my_catalog |\n| DATABASE_DRIVER | OPTIONAL - Used to override the default JDBC driver.  The scripts attempt to set the driver base on convention using `DATABASE_TYPE` | /app/lib/pgsql-jdbc.jar |\n| DATABASE_USER | The username to use when logging into the database.  When using OpenShift this should be configured as a secrete. |  my_user |\n| DATABASE_PASSWORD | The password to use when logging into the database.  When using OpenShift this should be configured as a secrete.|  my_password |\n| SCHEMASPY_ARGUMENTS | OPTIONAL - Allows you to define additional command line arguments for SchemaSpy |  `-hq` to generate high quality output. |\n| SCHEMASPY_COMMAND_OVERRIDE | OPTIONAL - Use this to override the SchemaSpy commands and define the commands explicitly.  This is intended as a testing and troubleshooting tool. | `lib/schemaspy.jar -t \"pgsql\" -db \"TheOrgBook_Database\" -dp \"lib/postgresql-jdbc.jar\" -hq -s \"public\" -u \"TheOrgBook_User\" -p \"*****\" -host \"postgresql\" -o /var/www/html` |\n| SCHEMASPY_PORT | OPTIONAL - Defaults to `8080`.  Changing this requires additional code and configuration changes, so it's best to leave it alone. | `8080` |\n| OUTPUT_PATH | OPTIONAL - The output folder for the documentation.  Defaults to `/var/www/html`, which is used by Caddy.  Changing this requires additional code and configuration changes, so it's best to leave it alone. | `/var/www/html` |\n| SCHEMASPY_PATH | OPTIONAL - The path to the SchemaSpy jar file.  Defaults to `lib/schemaspy.jar`.  Changing this requires additional code and configuration changes, so it's best to leave it alone. |  `lib/schemaspy.jar` |\n\n## Configuration - Backward Compatibility\n\nThe following environment variables are provided for drop-in backward compatibility with the previous SchemaSpy container implementation that only supported PostgreSQl databases (https://github.com/bcgov/SchemaSpy).\n\n| Name | Description | Example |\n| ---- | ------- | ------- |\n| DATABASE_SERVICE_NAME | Use `DATABASE_HOST` moving forward.  The hostname of the server |  postgresql |\n| POSTGRESQL_USER | Use `DATABASE_USER` moving forward.  The username to use when logging into the database.  When using OpenShift this should be configured as a secrete. |  my_user |\n| POSTGRESQL_PASSWORD | Use `DATABASE_PASSWORD` moving forward.  The password to use when logging into the database.  When using OpenShift this should be configured as a secrete.|  my_password |\n| POSTGRESQL_DATABASE | Use `DATABASE_NAME` moving forward.  The name of the database to document. | MyDatabase |\n\n## Running in OpenShift\n\nThe Dockerfile was designed to generate an image that can be used in OpenShift.\n\nAs a quick-start (example), the following command will create a BuildConfig, DeploymentConfig, and ancillary resources (service, etc.) in your current OpenShift project.\n\n```\noc new-app https://github.com/bcgov/SchemaSpy -e DATABASE_TYPE=pgsql -e DATABASE_NAME=default -e DATABASE_HOST=postgresql -e DATABASE_USER=django -e DB_PASSWORD=xyz1234 \n```\n\nFor more a more structured build and deployment environment, OpenShift templates can be found in the [OpenShift templates](./openshift/templates) folder.\n\n## Running in Docker\n\n### Build Command\n\n```\ndocker build -t schemaspy https://github.com/bcgov/SchemaSpy\n```\n\n### Sample MySQL Usage\n\n```\ndocker run -ti --rm --name schemaspy \\\n\t-p 8080:8080 \\\n\t-e DATABASE_TYPE=mysql \\\n\t-e DATABASE_HOST=mysql -e DATABASE_NAME=mydatabase \\\n\t-e DATABASE_USER=root -e DATABASE_PASSWORD=mysecretpassword \\\n\t--link mysql \\\n\tschemaspy\n```\n\n### Sample Postgres Usage\n\n```\ndocker run -ti --rm --name schemaspy \\\n\t-p 8080:8080 \\\n\t-e DATABASE_TYPE=pgsql \\\n\t-e DATABASE_HOST=postgres -e DATABASE_NAME=mydatabase \\\n\t-e DATABASE_USER=postgres -e DATABASE_PASSWORD=mysecretpassword \\\n\t--link postgres \\\n\tschemaspy\n```\n\n### Sample SQLite3 Usage\n\n```\nmkdir data \u0026\u0026 cp mydatabase.sqlite3 data/\ndocker run -ti --rm --name schemaspy \\\n\t-p 8080:8080 \\\n\t-v \"$PWD/data\":/app/data \\\n\t-e DATABASE_TYPE=sqlite \\\n\t-e DATABASE_NAME=/app/data/mydatabase.sqlite3 \\\n\tschemaspy\n```\n\n## Use on other databases\n\n### Oracle\n\nDue to licensing limitations, the JDBC drivers for Oracle are not included in the repository.\n\nLinks to the drivers can be found here;\n* https://www.oracle.com/technetwork/database/features/jdbc/index-091264.html\n* A link to the latest (ojdbc8.jar) drivers can be found here; https://www.oracle.com/technetwork/database/features/jdbc/jdbc-ucp-122-3110062.html\n\nUsing the Oracle Thin drivers it is easy to connect to an Oracle database.\n\nThe following configuraiton assumes you have downloaded the jar and copied it into the `./lib` folder of your working copy and run the following commands to generate the base image followed by the image containing the Oracle JDBC drivers.\n\n```\ndocker build -t 'schema-spy' .\ndocker build -f Dockerfile.oracle -t 'schema-spy-with-oracle-jdbc' .\n```\n\nYou can then use the [oc-push-image.sh](https://github.com/BCDevOps/openshift-developer-tools/blob/master/bin/oc-push-image.sh) from [OpenShift Scripts](https://github.com/BCDevOps/openshift-developer-tools/blob/master/bin/README.md) to push the image to your OpenShift project.\n\nFor example:\n```\noc-push-image.sh -i schema-spy-with-oracle-jdbc -n devex-von-bc-registries-agent-tools\n```\n\nConfiguration:\n\n| Name | Value | Description |\n| ---- | ------- | ------- |\n| DATABASE_TYPE | orathin | |\n| DATABASE_NAME | CUAT | The Oracle `SID` |\n| DATABASE_SCHEMA | COLIN_MGR_UAT | The Oracle `Schema` |\n| DATABASE_CATALOG | CUAT.bcgov | The Oracle `Listener Service Name` |\n| DATABASE_USER | username | |\n| DATABASE_PASSWORD | ***** | |\n| DATABASE_HOST | hostname:portnumber | *Hostname and port number MUST be specified.* |\n| DATABASE_DRIVER | lib/ora-jdbc.jar | |\n\nThe resulting SchemaSpy command looks something like this;\n```\njava -jar lib/schemaspy.jar -t \"orathin\" -db \"CUAT\" -dp \"lib/ora-jdbc.jar\" -s \"COLIN_MGR_UAT\" -cat \"CUAT.bcgov\" -u \"username\" -p \"*****\" -host \"hostname:portnumber\" -o /var/www/html\n```\n\n### Oracle - Through PostgreSQL oracle-fdw\n\n**Work in progress ...**\n\nA custom database configuration, [pgsql-oracle-fdw.properties](./conf/pgsql-oracle-fdw.properties), has been started for this purpose.\n\nThis allows SchemaSpy to query and graph the Foreign tables imported into PostgreSQL by oracle-fdw.\n\n*Current Limitations*\n\nThe oracle-fdw import process does not import any of the table constraints/relationships for any of the imported tables: since it wouldn't make sense to have constraints on the foreign tables, because PostgreSQL cannot guarantee that these constraints would be satisfied.\n\nTherefore, SchemaSpy will see the tables, but will be unable to wire up the relationships between the tables.  The result is a set of *orphaned* tables.\n\nThe recommended approach to fix this issue is to define a set of foreign tables on Oracle's catalog tables.  From there it should be possible to write a custom `selectCheckConstraintsSql` query for the `pgsql-oracle-fdw.properties` file that can provide SchemaSpy with the information it requires to wire the relationships between the tables.\n\nThis requires updates to the following projects;\n* [openshift-postgresql-oracle_fdw](https://github.com/bcgov/openshift-postgresql-oracle_fdw)\n  * Update to import the Oracle catalog tables.\n\n* [SchemaSpy - this project](https://github.com/bcgov/SchemaSpy)\n  * Write and test a custom `selectCheckConstraintsSql` query for the `pgsql-oracle-fdw.properties` file.\n\nExample Configuration:\n\n| Name | Value | Description |\n| ---- | ------- | ------- |\n| DATABASE_TYPE | pgsql-oracle-fdw | Tells SchemaSpy to use the `pgsql-oracle-fdw.properties` configuration file. |\n| DATABASE_NAME | BC_REGISTRIES | The name of the database from the PostgrSQL perspective. |\n| DATABASE_SCHEMA | bc_registries | The name of the schema from the PostgrSQL perspective. |\n| DATABASE_USER | username | The username for the related PostgrSQL database. |\n| DATABASE_PASSWORD | ***** | The password for the related PostgrSQL database. |\n| DATABASE_HOST | postgresql-oracle-fdw | The host of the PostgrSQL database. |\n\n## Code of Conduct\n\nPlease refer to the [Code of Conduct](./CODE_OF_CONDUCT.md) \n\n## Contributing\n\nWhat to add support for additional database types, or add additional features?\n\nFor information on how to contribute, refer to [Contributing](CONTRIBUTING.md)\n\n## License\n\nThe source code contained in this repository is released under the [Apache License, Version 2.0](./LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcgov%2FSchemaSpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbcgov%2FSchemaSpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcgov%2FSchemaSpy/lists"}