Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8

Overview

Summary

Generic Sequence brings Hibernate's SequenceStyleGenerator to Liquibase

Current Version

1.0.1

Author

Michael Oberwasserlechner

SVN Repository

https://liquibase.jira.com/svn/CONTRIB/trunk/liquibase-genericsequence/trunk

Supported Databases

Should work for all

Purpose

The main purpose of the genericSequence extension is to be able to use Hibernate’s SequenceStyleGenerator as a database-independent way of creating IDs for tables.

For more details please read the according section in the user guide, which might be found at 5.1.5. Enhanced identifier generators

Right now the extension supports

  • CreateGenericSequence
  • DropGenericSequence

How it works

Depending on the used database the extension checks if sequences are supported or not. In the first case a sequence is used in the other case a table.

Usage

You can use this extension as a child element in your changeSets.

Example:

<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd
    http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

  <changeSet id="create_data_language" author="michael">
    <ext:createGenericSequence sequenceName="SQ_DATA_LANGUAGE" incrementBy="1" startValue="10000"/>

    <createTable tableName="DATA_LANGUAGE" remarks="This table stores the data language definitions.">
      <column name="ID" type="NUMBER(10)">
        <constraints primaryKeyName="PK_DATA_LANGUAGE" primaryKey="true"/>
      </column>
      <column name="ISO_CODE" type="VARCHAR(10)" >
        <constraints nullable="false" unique="true"/>
      </column>
    </createTable>
  </changeSet>
</databaseChangeLog>

XSD:

<?xml version="1.0" encoding="UTF-8"?>

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.liquibase.org/xml/ns/dbchangelog-ext"
  xmlns="http://www.liquibase.org/xml/ns/dbchangelog-ext"
  elementFormDefault="qualified">

  <xsd:element name="createGenericSequence">
    <xsd:complexType>
      <xsd:attribute name="schemaName" type="xsd:string"/>
      <xsd:attribute name="sequenceName" type="xsd:string" use="required"/>
      <xsd:attribute name="startValue" type="xsd:integer" default="1"/>
      <xsd:attribute name="minValue" type="xsd:integer"/>
      <xsd:attribute name="maxValue" type="xsd:integer"/>
      <xsd:attribute name="incrementBy" type="xsd:integer" default="1"/>
      <xsd:attribute name="forceTableUse" type="xsd:boolean" default="false"/>
      <xsd:attribute name="tableValueColumnName" type="xsd:string" default="next_val" />
      <xsd:attribute name="tableValueColumnSize" type="xsd:integer" default="10" />
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="dropGenericSequence">
    <xsd:complexType>
      <xsd:attribute name="schemaName" type="xsd:string" />
      <xsd:attribute name="sequenceName" type="xsd:string" use="required"/>
      <xsd:attribute name="forceTableUse" type="xsd:boolean" default="false"/>
    </xsd:complexType>
  </xsd:element>

</xsd:schema>

Files

  File Modified
You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.
No files shared here yet.
  • Drag and drop to upload or browse for files
    • No labels