diff --git a/sql/Makefile b/sql/Makefile index c6cab721..9b819237 100644 --- a/sql/Makefile +++ b/sql/Makefile @@ -1,49 +1,50 @@ # Depends: postgresql-client, postgresql-autodoc DBNAME = softwareheritage-dev DOCDIR = autodoc SQL_INIT = swh-init.sql SQL_SCHEMA = swh-schema.sql SQL_FUNC = swh-func.sql SQL_DATA = swh-data.sql SQLS = $(SQL_INIT) $(SQL_SCHEMA) $(SQL_FUNC) $(SQL_DATA) PSQL_BIN = psql PSQL_FLAGS = --single-transaction --echo-all PSQL = $(PSQL_BIN) $(PSQL_FLAGS) all: createdb: createdb-stamp createdb-stamp: $(SQL_INIT) createdb $(DBNAME) touch $@ filldb: filldb-stamp filldb-stamp: createdb-stamp cat $(SQLS) | $(PSQL) $(DBNAME) touch $@ dropdb: dropdb $(DBNAME) dumpdb: swh.dump swh.dump: filldb-stamp pg_dump -Fc $(DBNAME) > $@ doc: doc-stamp doc-stamp: filldb-stamp test -d $(DOCDIR)/ || mkdir $(DOCDIR) postgresql_autodoc -d $(DBNAME) -f $(DOCDIR)/swh + bin/dot_add_content $(DOCDIR)/swh.dot clusters.dot dot -T pdf $(DOCDIR)/swh.dot > $(DOCDIR)/swh.pdf touch $@ clean: rm -rf *-stamp $(DOCDIR)/ distclean: clean dropdb rm -f swh.dump .PHONY: all initdb createdb dropdb doc clean diff --git a/sql/bin/dot_add_content b/sql/bin/dot_add_content new file mode 100755 index 00000000..679fdf31 --- /dev/null +++ b/sql/bin/dot_add_content @@ -0,0 +1,20 @@ +#!/bin/bash + +# Depends: moreutils + +DOT_FILE="$1" +DOT_EXTRA="$2" +if [ -z "$DOT_FILE" -o -z "$DOT_EXTRA" ] ; then + echo "Usage: $0 DOT_FILE DOT_EXTRA" + exit 1 +fi + +if ! [ -x $(which sponge) ] ; then + echo "Can't find sponge. Please: apt-get install moreutils" + exit 1 +fi + +(head -n -1 "$DOT_FILE" ; + cat "$DOT_EXTRA" ; + echo "}") \ + | sponge "$DOT_FILE" diff --git a/sql/clusters.dot b/sql/clusters.dot new file mode 100644 index 00000000..92101753 --- /dev/null +++ b/sql/clusters.dot @@ -0,0 +1,58 @@ +subgraph cluster_meta { + label = "Meta"; + dbversion; +} + +subgraph cluster_content { + label = "Content"; + content; +} + +subgraph cluster_directory { + label = "Directories"; + directory; + directory_entry_dir; + directory_entry_file; + directory_list_dir; + directory_list_file; +} + +directory_entry_file -> content; + +subgraph cluster_revision { + label = "Revisions"; + revision; + revision_history; + person; +} + +revision -> directory; + +subgraph cluster_release { + label = "Releases"; + release; +} + +subgraph cluster_occurrences { + label = "Occurrences"; + occurrence; + occurrence_history; +} + +subgraph cluster_origins { + label = "Origins"; + origin; + fetch_history; +} + +subgraph cluster_projects { + label = "Projects"; + project; + project_history; +} + +subgraph cluster_organization { + label = "Organizations"; + organization; + list_history; +}