diff --git a/sql/Makefile b/sql/Makefile index f42c7520..7aa86d35 100644 --- a/sql/Makefile +++ b/sql/Makefile @@ -1,71 +1,71 @@ # Depends: postgresql-client, postgresql-autodoc DBNAME = softwareheritage-dev DOCDIR = autodoc -SQL_FILES = $(sort $(wildcard $(CURDIR)/../swh/storage/sql/*)) +SQL_FILES = $(sort $(wildcard $(CURDIR)/../swh/storage/sql/*.sql)) PSQL_BIN = psql PSQL_FLAGS = --echo-errors -X -v ON_ERROR_STOP=1 PSQL = $(PSQL_BIN) $(PSQL_FLAGS) PIFPAF=$(findstring postgresql://,$(PIFPAF_URLS)) all: createdb: createdb-stamp createdb-stamp: $(SQL_FILES) ifeq ($(PIFPAF),) -dropdb $(DBNAME) endif createdb $(DBNAME) ifeq ($(PIFPAF),) touch $@ else rm -f $@ endif filldb: filldb-stamp filldb-stamp: createdb-stamp cat $(SQL_FILES) | $(PSQL) $(DBNAME) ifeq ($(PIFPAF),) touch $@ else rm -f $@ endif dropdb: -dropdb $(DBNAME) dumpdb: swh.dump swh.dump: filldb-stamp pg_dump -Fc $(DBNAME) > $@ $(DOCDIR): test -d $(DOCDIR)/ || mkdir $(DOCDIR) doc: autodoc-stamp $(DOCDIR)/db-schema.pdf $(DOCDIR)/db-schema.svg autodoc-stamp: filldb-stamp $(DOCDIR) postgresql_autodoc -d $(DBNAME) -f $(DOCDIR)/db-schema cp -a $(DOCDIR)/db-schema.dot $(DOCDIR)/db-schema.dot.orig ifeq ($(PIFPAF),) touch $@ else rm -f $@ endif $(DOCDIR)/db-schema.dot: clusters.dot autodoc-stamp $(DOCDIR) bin/dot_add_content $(DOCDIR)/db-schema.dot.orig clusters.dot > $(DOCDIR)/db-schema.dot $(DOCDIR)/db-schema.pdf: $(DOCDIR)/db-schema.dot autodoc-stamp dot -T pdf $< > $@ $(DOCDIR)/db-schema.svg: $(DOCDIR)/db-schema.dot autodoc-stamp dot -T svg $< > $@ 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 index b462d8d9..8a415f51 100755 --- a/sql/bin/dot_add_content +++ b/sql/bin/dot_add_content @@ -1,20 +1,20 @@ #!/bin/bash DOT_FILE="$1" DOT_EXTRA="$2" -SQL_SCHEMA="../swh/storage/sql/30-swh-schema.sql" +SQL_SCHEMA="../swh/storage/sql/30-schema.sql" if [ -z "$DOT_FILE" -o -z "$DOT_EXTRA" ] ; then echo "Usage: $0 DOT_FILE DOT_EXTRA" exit 1 fi if ! [ -f "$SQL_SCHEMA" ] ; then echo "Cannot find SQL schema ${SQL_SCHEMA}" 1>&2 exit 2 fi schema_version=$(grep -i -A 1 '^insert into dbversion' "$SQL_SCHEMA" | tail -n 1 \ | sed -e 's/.*values(//i' -e 's/,.*//') head -n -1 "$DOT_FILE" # all of $DOT_FILE but last line sed "s/@@VERSION@@/$schema_version/" "$DOT_EXTRA" echo "}"