meta ddl генератор: пересоздание таблиц через drop table.; поправил comment-objects COMMENT ON COLUMN;добавление поля *_HISTORY.EVENT_TYPE
This commit is contained in:
parent
e8c4088976
commit
5d23338904
1 changed files with 194 additions and 191 deletions
|
|
@ -37,7 +37,8 @@
|
||||||
<xsl:template match="*" mode="enums">
|
<xsl:template match="*" mode="enums">
|
||||||
-- <xsl:value-of select="name()"/> - <xsl:value-of select="@name"/>
|
-- <xsl:value-of select="name()"/> - <xsl:value-of select="@name"/>
|
||||||
<xsl:variable name="dbTableName"><xsl:call-template name='convertDbStyle'><xsl:with-param name='toconvert' select='concat(name(),"Dictionary")'/></xsl:call-template></xsl:variable>
|
<xsl:variable name="dbTableName"><xsl:call-template name='convertDbStyle'><xsl:with-param name='toconvert' select='concat(name(),"Dictionary")'/></xsl:call-template></xsl:variable>
|
||||||
CREATE TABLE IF NOT EXISTS <xsl:value-of select="$dbTableName"/>(<xsl:apply-templates select="*" mode="field"/>);
|
DROP TABLE IF EXISTS <xsl:value-of select="$dbTableName"/>;
|
||||||
|
CREATE TABLE <xsl:value-of select="$dbTableName"/>(<xsl:apply-templates select="*" mode="field"/>);
|
||||||
COMMENT ON TABLE <xsl:value-of select="$dbTableName"/> IS '<xsl:value-of select="@name"/>';
|
COMMENT ON TABLE <xsl:value-of select="$dbTableName"/> IS '<xsl:value-of select="@name"/>';
|
||||||
<xsl:apply-templates select="*" mode="comment-enums"/>
|
<xsl:apply-templates select="*" mode="comment-enums"/>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
@ -45,18 +46,21 @@ COMMENT ON TABLE <xsl:value-of select="$dbTableName"/> IS '<xsl:value-of select=
|
||||||
<xsl:template match="*" mode="objects">
|
<xsl:template match="*" mode="objects">
|
||||||
-- <xsl:value-of select="name()"/> - <xsl:value-of select="@name"/>
|
-- <xsl:value-of select="name()"/> - <xsl:value-of select="@name"/>
|
||||||
<xsl:variable name="dbTableName"><xsl:call-template name='convertDbStyle'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template></xsl:variable>
|
<xsl:variable name="dbTableName"><xsl:call-template name='convertDbStyle'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template></xsl:variable>
|
||||||
CREATE TABLE IF NOT EXISTS <xsl:value-of select="$dbTableName"/>(<xsl:apply-templates select="*[@name or @type]" mode="field"/>);
|
DROP TABLE IF EXISTS <xsl:value-of select="$dbTableName"/>;
|
||||||
|
CREATE TABLE <xsl:value-of select="$dbTableName"/>(<xsl:apply-templates select="*[@name or @type]" mode="field"/>);
|
||||||
COMMENT ON TABLE <xsl:value-of select="$dbTableName"/> IS '<xsl:value-of select="@name"/>';
|
COMMENT ON TABLE <xsl:value-of select="$dbTableName"/> IS '<xsl:value-of select="@name"/>';
|
||||||
<xsl:apply-templates select="*[@name or @type]" mode="comment-objects"/>
|
<xsl:apply-templates select="*[@name or @type]" mode="comment-objects"/>
|
||||||
<xsl:if test="@logUpdates">
|
<xsl:if test="@logUpdates">
|
||||||
|
|
||||||
-- History log of <xsl:value-of select="name()"/> - <xsl:value-of select="@name"/>
|
-- History log of <xsl:value-of select="name()"/> - <xsl:value-of select="@name"/>
|
||||||
<xsl:variable name="dbTableName"><xsl:call-template name='convertDbStyle'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template></xsl:variable>
|
<xsl:variable name="dbTableName"><xsl:call-template name='convertDbStyle'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template></xsl:variable>
|
||||||
CREATE TABLE IF NOT EXISTS <xsl:value-of select="$dbTableName"/>_HISTORY(<xsl:value-of select="$dbTableName"/>_ID BIGINT NOT NULL, EVENT_TIME timestamp, EVENT_USER_ID BIGINT, <xsl:apply-templates select="*[@name or @type]" mode="field"/>);
|
DROP TABLE IF EXISTS <xsl:value-of select="$dbTableName"/>_HISTORY;
|
||||||
|
CREATE TABLE <xsl:value-of select="$dbTableName"/>_HISTORY(<xsl:value-of select="$dbTableName"/>_ID BIGINT NOT NULL, EVENT_TIME timestamp, EVENT_USER_ID BIGINT, EVENT_TYPE VARCHAR(4), <xsl:apply-templates select="*[@name or @type]" mode="field"/>);
|
||||||
COMMENT ON TABLE <xsl:value-of select="$dbTableName"/>_HISTORY IS 'История изменений таблицы <xsl:value-of select="name()"/>';
|
COMMENT ON TABLE <xsl:value-of select="$dbTableName"/>_HISTORY IS 'История изменений таблицы <xsl:value-of select="name()"/>';
|
||||||
COMMENT ON COLUMN <xsl:value-of select="$dbTableName"/>_HISTORY.<xsl:value-of select="$dbTableName"/>_ID IS 'Идентификатор записи в таблице <xsl:value-of select="$dbTableName"/>';
|
COMMENT ON COLUMN <xsl:value-of select="$dbTableName"/>_HISTORY.<xsl:value-of select="$dbTableName"/>_ID IS 'Идентификатор записи в таблице <xsl:value-of select="$dbTableName"/>';
|
||||||
COMMENT ON COLUMN <xsl:value-of select="$dbTableName"/>_HISTORY.EVENT_TIME IS 'Дата и время изменения';
|
COMMENT ON COLUMN <xsl:value-of select="$dbTableName"/>_HISTORY.EVENT_TIME IS 'Дата и время изменения';
|
||||||
COMMENT ON COLUMN <xsl:value-of select="$dbTableName"/>_HISTORY.EVENT_USER_ID IS 'Инициатор изменения';
|
COMMENT ON COLUMN <xsl:value-of select="$dbTableName"/>_HISTORY.EVENT_USER_ID IS 'Инициатор изменения';
|
||||||
|
COMMENT ON COLUMN <xsl:value-of select="$dbTableName"/>_HISTORY.EVENT_TYPE IS 'Тип изменения';
|
||||||
<xsl:apply-templates select="*[@name or @type]" mode="comment-history-objects"/>
|
<xsl:apply-templates select="*[@name or @type]" mode="comment-history-objects"/>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
@ -92,9 +96,8 @@ COMMENT ON COLUMN <xsl:value-of select="$dbTableName"/>.<xsl:call-template name=
|
||||||
<xsl:when test="@extends"></xsl:when>
|
<xsl:when test="@extends"></xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:variable name="dbTableName"><xsl:call-template name='convertDbStyle'><xsl:with-param name='toconvert' select='name(parent::*)'/></xsl:call-template></xsl:variable>
|
<xsl:variable name="dbTableName"><xsl:call-template name='convertDbStyle'><xsl:with-param name='toconvert' select='name(parent::*)'/></xsl:call-template></xsl:variable>
|
||||||
COMMENT ON COLUMN <xsl:value-of select="$dbTableName"/>.<xsl:call-template name='convertDbStyle'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template></xsl:otherwise>
|
COMMENT ON COLUMN <xsl:value-of select="$dbTableName"/>.<xsl:call-template name='convertDbStyle'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template> IS '<xsl:if test="@name"><xsl:value-of select="@name"/></xsl:if> <xsl:if test="@link"> (linked to <xsl:value-of select="@link"/>)</xsl:if>';
|
||||||
</xsl:choose> IS '<xsl:if test="@name"><xsl:value-of select="@name"/></xsl:if> <xsl:if test="@link"> (linked to <xsl:value-of select="@link"/>)</xsl:if>';
|
</xsl:otherwise></xsl:choose></xsl:template>
|
||||||
</xsl:template>
|
|
||||||
|
|
||||||
<xsl:template match="*" mode="comment-history-objects"><!-- todo похож на comment-objects только именем таблицы различается попробовать объединить -->
|
<xsl:template match="*" mode="comment-history-objects"><!-- todo похож на comment-objects только именем таблицы различается попробовать объединить -->
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue