Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store database schema picture in repository #692

Closed
abitrolly opened this issue Jan 7, 2019 · 20 comments · Fixed by #871
Closed

Store database schema picture in repository #692

abitrolly opened this issue Jan 7, 2019 · 20 comments · Fixed by #871
Labels
easyfix Low Priority This ticket has a low priority type.bug

Comments

@abitrolly
Copy link
Contributor

It is handy to have the picture https://release-monitoring.org/static/docs/database.html#database-schema versioned in docs/ for historical purpose.

image

@Zlopez Zlopez added type.feature New feature Low Priority This ticket has a low priority easyfix labels Jan 8, 2019
@yarons
Copy link
Contributor

yarons commented Jan 30, 2019

I followed the link and it looks like the picture is already there, can this be closed?

@Zlopez Zlopez added type.bug and removed type.feature New feature labels Jan 30, 2019
@Zlopez
Copy link
Contributor

Zlopez commented Jan 30, 2019

The issue is that the image is not part of the repository, thus it isn't versioned. I looked at the official documentation and the picture is missing there :-(, because it couldn't find it in the path. I need to fix this.

@abitrolly
Copy link
Contributor Author

I wish there was an "Awesome Database Picture Generators".

@Zlopez
Copy link
Contributor

Zlopez commented Apr 30, 2019

Implementations details

This just needs to remove docs/images from .gitignore.

@abitrolly
Copy link
Contributor Author

Looks what I found - https://github.com/schemacrawler/SchemaCrawler

@abitrolly
Copy link
Contributor Author

Trying another tool - https://github.com/schemaspy/schemaspy

# schemaspy
# Graphical Database Schema Generator <https://github.com/schemaspy/schemaspy>.

# Show supported DB connection parameters:
podman run -it schemaspy/schemaspy -dbhelp

@abitrolly
Copy link
Contributor Author

Using schemaspy:snapshot until 6.1.0 schemaspy/schemaspy#579 is released.

For Anitya, only connection parameters for sqlite and PostgreSQL are relevant.

$ podman run -it schemaspy/schemaspy:snapshot -dbhelp
...
INFO  - PostgreSQL
INFO  - Usage -t pgsql
INFO  -    -host   		host of database, may contain port
INFO  -    -port   		optional port if not default
INFO  -    -db   		database name
INFO  - PostgreSQL
INFO  - Usage -t pgsql11
INFO  -    -host   		host of database, may contain port
INFO  -    -port   		optional port if not default
INFO  -    -db   		database name
...
INFO  - SQLite
INFO  - Usage -t sqlite
INFO  -    -db   		path to database or :memory:
INFO  - SQLite
INFO  - Usage -t sqlite-xerial
INFO  -    -db   		path to database or :memory:

@abitrolly
Copy link
Contributor Author

Trying newer version with my fix for help output.

$ podman pull schemaspy/schemaspy:snapshot && podman run -it schemaspy/schemaspy:snapshot -dbhelp
...
INFO  - PostgreSQL (-t pgsql)
INFO  -    -host   		host of database, may contain port
INFO  -    -port   		optional port if not default
INFO  -    -db   		database name
INFO  - PostgreSQL (-t pgsql11)
INFO  -    -host   		host of database, may contain port
INFO  -    -port   		optional port if not default
INFO  -    -db   		database name
...
INFO  - SQLite (-t sqlite)
INFO  -    -db   		path to database or :memory:
INFO  - SQLite (-t sqlite-xerial)
INFO  -    -db   		path to database or :memory:

@Zlopez
Copy link
Contributor

Zlopez commented Aug 5, 2019

Could you post the output, so we can see how it looks?

@abitrolly
Copy link
Contributor Author

@Zlopez went deep down the rabbit hole, no specific output for Anitya yet.

I found that latest pages on RTD are missing the database diagram.

image

That's because RTD executes sphinx-build directly instead of make. https://readthedocs.org/projects/anitya/builds/9439395/ The solution is to include DB generation as an extension into conf.py.

@abitrolly
Copy link
Contributor Author

I am trying to get the output for anitya using PostgreSQL

# download dump
$ wget https://infrastructure.fedoraproject.org/infra/db-dumps/anitya.dump.xz
# start postgresql in container
$ podman run --name some-postgres -d postgres
# insert dump into image
$ podman cp anitya.dump.xz some-postgres:/anitya.dump.xz

TBC

@abitrolly
Copy link
Contributor Author

# unpack dump inside of the image
$ podman exec some-postgres unxz /anitya.dump.xz
# restore database dump
$ podman exec -it -u postgres some-postgres psql -f /anitya.dump
...
SET
CREATE TABLE
psql:/anitya.dump:57: ERROR:  role "anitya_admin" does not exist
CREATE TABLE
...
REVOKE
psql:/anitya.dump:451553: ERROR:  role "anitya_admin" does not exist
psql:/anitya.dump:451554: ERROR:  role "anitya_admin" does not exist
psql:/anitya.dump:451555: ERROR:  role "anitya" does not exist

I don't know how to setup those users at the moment. Database schema picture is unlikely to be affected by access control setup.

@Zlopez
Copy link
Contributor

Zlopez commented Sep 5, 2019

@abitrolly This is how the db is handled in ansible provisioning script https://github.com/release-monitoring/anitya/blob/master/ansible/roles/anitya-dev/tasks/db.yml

@abitrolly
Copy link
Contributor Author

@Zlopez yes, I looked into that. Still not enough time to get into PostgreSQL user configuration.

@abitrolly
Copy link
Contributor Author

abitrolly commented Sep 5, 2019

Forgot to expose port in some-postgres container. Have to install ssh and jump through https://serveo.net

$ podman run -it schemaspy/schemaspy:snapshot -u postgres -t pgsql11 -host serveo.net -port 5432 -db anitya
...
INFO  - View the results by opening /output/index.html

(-t pgsql throwed errors)

Can not get files from outside container. Because postres user used for authentication from inside of container has no privileges to write on host. Not sure how to fix that right now.

$ podman run -it -v "$PWD"/html:/output:Z schemaspy/schemaspy:snapshot -u postgres -t pgsql11 -host serveo.net -port 5432 -db anitya
...
INFO  - Started Main in 1.993 seconds (JVM running for 2.735)
INFO  - Starting schema analysis
ERROR - IOException
Unable to create directory /output/tables
INFO  - StackTraces have been omitted, use `-debug` when executing SchemaSpy to see them

@abitrolly
Copy link
Contributor Author

I got it wrong. schemaspy container runs with java user, not postgres, and this user is unable to write to $PWD/html too. The solution is to run container without the volume, and then manually cp files from there.

✗ podman run -d schemaspy/schemaspy:snapshot -u postgres -t pgsql11 -host serveo.net -port 5432 -db anitya
bd8aed521b7114b0c701231da949b4a8646f622e2601f2e54c8cf5024911a729
# wait until it stops and get files
✗ podman cp bd8aed52:/output ./html

@abitrolly
Copy link
Contributor Author

SchemeSpy generates html report. I past one picture from four generated. The full report is in attach.

image

schemaspy-anitya.tar.gz

@Zlopez
Copy link
Contributor

Zlopez commented Sep 12, 2019

This looks really nice. Only the information about number of rows is irrelevant.

@abitrolly
Copy link
Contributor Author

Also some inferred relationships are wrong and tables without relationships are missing on this view. )

@Zlopez
Copy link
Contributor

Zlopez commented Sep 12, 2019

Good catch, I didn't noticed the missing tables.

Zlopez added a commit to Zlopez/anitya that referenced this issue Dec 19, 2019
Database image was missing in the documentation, because it was not in
the repository. This commit is fixing this.

Fixes fedora-infra#692

Signed-off-by: Michal Konečný <[email protected]>
Zlopez added a commit to Zlopez/anitya that referenced this issue Jan 8, 2020
Database image was missing in the documentation, because it was not in
the repository. This commit is fixing this.

Fixes fedora-infra#692

Signed-off-by: Michal Konečný <[email protected]>
Zlopez added a commit that referenced this issue Jan 8, 2020
Database image was missing in the documentation, because it was not in
the repository. This commit is fixing this.

Fixes #692

Signed-off-by: Michal Konečný <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easyfix Low Priority This ticket has a low priority type.bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants