Skip to content

Commit

Permalink
reorder sql script for postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
loro2 committed Aug 2, 2019
1 parent d6437c6 commit cae88ca
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions db/postgresql/output.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -107,29 +107,6 @@

</xsl:for-each>


<!-- fk -->
<xsl:for-each select="row">
<xsl:for-each select="relation">
<xsl:text>ALTER TABLE </xsl:text>
<xsl:value-of select="../../@name" />
<xsl:text> ADD CONSTRAINT </xsl:text>
<xsl:value-of select="../../@name" />
<xsl:text>_</xsl:text>
<xsl:value-of select="../@name" />
<xsl:text>_fkey</xsl:text>
<xsl:text> FOREIGN KEY (</xsl:text>
<xsl:value-of select="../@name" />
<xsl:text>) REFERENCES </xsl:text>
<xsl:value-of select="@table" />
<xsl:text>(</xsl:text>
<xsl:value-of select="@row" />
<xsl:text>);
</xsl:text>
</xsl:for-each>
</xsl:for-each>


<xsl:if test="comment">
<xsl:text>COMMENT ON TABLE "</xsl:text>
<xsl:value-of select="@name"/>
Expand Down Expand Up @@ -165,5 +142,29 @@
</xsl:text>
</xsl:for-each>

<!-- tables -->
<xsl:for-each select="table">
<!-- fk -->
<xsl:for-each select="row">
<xsl:for-each select="relation">
<xsl:text>ALTER TABLE </xsl:text>
<xsl:value-of select="../../@name" />
<xsl:text> ADD CONSTRAINT </xsl:text>
<xsl:value-of select="../../@name" />
<xsl:text>_</xsl:text>
<xsl:value-of select="../@name" />
<xsl:text>_fkey</xsl:text>
<xsl:text> FOREIGN KEY (</xsl:text>
<xsl:value-of select="../@name" />
<xsl:text>) REFERENCES </xsl:text>
<xsl:value-of select="@table" />
<xsl:text>(</xsl:text>
<xsl:value-of select="@row" />
<xsl:text>);
</xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>

</xsl:template>
</xsl:stylesheet>

0 comments on commit cae88ca

Please sign in to comment.