[sr-dev] git:master:7b0de5ca: srdb1/schema: make target to generate schema for mongodb

Daniel-Constantin Mierla miconda at gmail.com
Wed Sep 9 09:22:13 CEST 2015


Module: kamailio
Branch: master
Commit: 7b0de5ca923b4427b669282edffde054c58b682a
URL: https://github.com/kamailio/kamailio/commit/7b0de5ca923b4427b669282edffde054c58b682a

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2015-09-09T09:21:56+02:00

srdb1/schema: make target to generate schema for mongodb

---

Modified: lib/srdb1/schema/Makefile

---

Diff:  https://github.com/kamailio/kamailio/commit/7b0de5ca923b4427b669282edffde054c58b682a.diff
Patch: https://github.com/kamailio/kamailio/commit/7b0de5ca923b4427b669282edffde054c58b682a.patch

---

diff --git a/lib/srdb1/schema/Makefile b/lib/srdb1/schema/Makefile
index 3bc39d2..9eac430 100644
--- a/lib/srdb1/schema/Makefile
+++ b/lib/srdb1/schema/Makefile
@@ -33,6 +33,9 @@ DB_SQLITE_XSL = $(STYLESHEETS)/db_sqlite.xsl
 # Stylesheet used to generate oracle database schema
 ORACLE_XSL = $(STYLESHEETS)/oracle.xsl
 
+# Stylesheet used to generate mongodb database schema
+MONGODB_XSL = $(STYLESHEETS)/mongodb.xsl
+
 # Stylesheet used to generate docbook documentation
 DOCBOOK_XSL = $(STYLESHEETS)/docbook.xsl
 
@@ -195,6 +198,35 @@ db_sqlite:
 db_sqlite_clean:
 	- at rm -f $(SCHEME)/db_sqlite/*
 
+.PHONY: mongodb mongodb_clean
+mongodb:
+	for FILE in $(TABLES); do \
+		XML_CATALOG_FILES=$(CATALOG) $(XSLTPROC) $(XSLTPROC_FLAGS) \
+		--stringparam dir "$(SCHEME)/mongodb/kamailio" \
+		--stringparam prefix "" \
+		--stringparam db "mongodb" \
+		$(MONGODB_XSL) kamailio-"$$FILE".xml ; \
+	done
+	@# small hack to create the version table entries, this is here easier as with XSL
+	@echo "use kamailio;" \
+		> "$(SCHEME)/dbtext/kamailio/version-create.mongo" ;
+	@echo "db.createCollection(\"version\");" \
+		>> "$(SCHEME)/dbtext/kamailio/version-create.mongo" ;
+	@for FILE in $(sort $(wildcard $(SCHEME)/mongodb/kamailio/*.json)) ; do \
+		if [ -f "$$FILE" ]; then \
+			if [  "$$FILE" != "$(SCHEME)/mongodb/kamailio/version.json" ]; then \
+				VN=`grep '"version":' "$$FILE" | grep -o -E '[0-9]+'` ; \
+				FN=`basename $$FILE .json` ;\
+				echo "db.getCollection(\"version\").insert({ table_name: \"$$FN\", table_version: NumberInt($$VN) });" \
+						>> "$(SCHEME)/dbtext/kamailio/version-create.mongo" ; \
+			fi ; \
+		fi ; \
+	done ; \
+
+mongodb_clean:
+	- at rm -f $(SCHEME)/mongodb/kamailio/*
+
+
 .PHONY: docbook-xml
 docbook-xml:
 	for FILE in $(TABLES); do \




More information about the sr-dev mailing list