From 42fccbdb0af9671058abff3988de5a983dd73de8 Mon Sep 17 00:00:00 2001 From: bidecho Date: Sat, 11 Mar 2017 23:18:12 -0800 Subject: [PATCH] Revision to postgresql schema generator This modification makes the schema format more in-line with good practice for postgresql table schema writing. It also makes it work with some tools that read postgresql schemas to generate code, and need the schema to be a certain format (i.e. SQLBoiler for golang). --- db/postgresql/output.xsl | 81 +++++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 34 deletions(-) diff --git a/db/postgresql/output.xsl b/db/postgresql/output.xsl index 4ca7866..39cc978 100644 --- a/db/postgresql/output.xsl +++ b/db/postgresql/output.xsl @@ -26,14 +26,14 @@ - CREATE TABLE " + CREATE TABLE - " ( + ( - " + - " + @@ -43,23 +43,23 @@ column with nextval(). see: http://www.postgresql.org/docs/current/static/datatype-numeric.html#DATATYPE-SERIAL --> - SERIAL + SERIAL - + - NOT NULL + NOT NULL - DEFAULT + DEFAULT - + @@ -75,10 +75,21 @@ + +); + + + + - , - + ALTER TABLE + + + + ADD CONSTRAINT + + _pkey PRIMARY KEY ( UNIQUE ( @@ -86,18 +97,38 @@ - "" + , - ) + ); + - - -); + + + + + + ALTER TABLE + + ADD CONSTRAINT + + _ + + _fkey + FOREIGN KEY ( + + ) REFERENCES + + ( + + ); + + + COMMENT ON TABLE " @@ -134,23 +165,5 @@ - - - - - ALTER TABLE " - - " ADD FOREIGN KEY (" - - ") REFERENCES " - - " (" - - "); - - - - -