Giter Club home page Giter Club logo

liquibase-spatial's Introduction

Liquibase Spatial

Liquibase Spatial is an extension to Liquibase to handle spatial indexing and geometry types. It requires Liquibase 3.1.1 or newer.

Liquibase Version Liquibase Spatial Version
Liquibase 3.1.1 Liquibase Spatial 1.0.x
Liquibase 3.2.x Liquibase Spatial 1.1.x
Liquibase 3.3.x Liquibase Spatial 1.2.x

In order to use this extension, you must have the liquibase-spatial jar in your classpath. For XML change logs, define the spatial namespace as below:

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
   xmlns:spatial="http://www.liquibase.org/xml/ns/dbchangelog-ext/liquibase-spatial"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
      http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd 
   http://www.liquibase.org/xml/ns/dbchangelog-ext/liquibase-spatial 
      http://lonnyj.github.com/liquibase-spatial/liquibase-spatial.xsd">
</databaseChangeLog>

Using the XML elements defined by this extension requires specifying the spatial namespace prefix on those elements. Here is a quick example of how to create a table with a geometry column, create a spatial index on that column, and insert data into the table:

<changeSet id="Create table" author="bob">
   <preConditions>
      <spatial:spatialSupported />
   </preConditions>
   <createTable tableName="EXAMPLE">
      <column name="ID" type="BIGINT">
         <constraints nullable="false" primaryKey="true" primaryKeyName="EXAMPLE_PK" />
      </column>
      <column name="GEOM" type="GEOMETRY(Point, 4326)">
         <constraints nullable="false" />
      </column>
   </createTable>
</changeSet>

<changeSet id="Create spatial index" author="bob">
   <preConditions>
      <not>
         <spatial:spatialIndexExists tableName="EXAMPLE" columnNames="GEOM" />
      </not>
   </preConditions>
   <spatial:createSpatialIndex tableName="EXAMPLE" indexName="EXAMPLE_GEOM_IDX" geometryType="Point" srid="4326">
      <column name="GEOM" />
   </spatial:createSpatialIndex>
</changeSet>

<changeSet id="Insert spatial data" author="bob">
   <insert tableName="EXAMPLE">
      <column name="ID" valueNumeric="1" />
      <column name="GEOM" value="SRID=4326;POINT(-5 -5)" />
   </insert>
   <insert tableName="EXAMPLE">
      <column name="ID" valueNumeric="2" />
      <column name="GEOM" value="SRID=4326;POINT(0 0)" />
   </insert>
   <insert tableName="EXAMPLE">
      <column name="ID" valueNumeric="3" />
      <column name="GEOM" value="SRID=4326;POINT(5 5)" />
   </insert>
</changeSet>

Refer to the documentation for further information.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.