<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Wysmedia.com &#187; java</title>
	<atom:link href="http://www.wysmedia.com/category/programming/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wysmedia.com</link>
	<description>~ We make IT easy for you ~</description>
	<lastBuildDate>Fri, 08 May 2009 07:02:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Native SQL Query on Grails</title>
		<link>http://www.wysmedia.com/2009/05/native-sql-query-on-grails/</link>
		<comments>http://www.wysmedia.com/2009/05/native-sql-query-on-grails/#comments</comments>
		<pubDate>Mon, 04 May 2009 14:50:44 +0000</pubDate>
		<dc:creator>adwin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.wysmedia.com/?p=76</guid>
		<description><![CDATA[As we know, Hibernate Query Language or using GORM are not enough, for example if we want to create complex queries or using native sql functions ie. date() function in MySQL. That&#8217;s why we need to use Groovy SQL to achive that.
 
Before we started, I want to let you know that once we using [...]]]></description>
			<content:encoded><![CDATA[<p>As we know, Hibernate Query Language or using GORM are not enough, for example if we want to create complex queries or using native sql functions ie. date() function in MySQL. That&#8217;s why we need to use Groovy SQL to achive that.</p>
<p> <span id="more-76"></span></p>
<p>Before we started, I want to let you know that once we using native functions in sql, we might got problem when we tried to deploy on another database server. So be wise.</p>
<p>Here is simple example how to do that :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">groovy.sql.Sql</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> ReportController <span style="color: #66cc66;">&#123;</span> 
    <span style="color: #000000; font-weight: bold;">def</span> dataSource <span style="color: #66cc66;">;</span> 
    .....
    <span style="color: #000000; font-weight: bold;">def</span> <span style="color: #993399;">print</span> <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
        .....
        <span style="color: #000000; font-weight: bold;">def</span> sql <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #993399; font-weight: bold;">Sql</span><span style="color: #66cc66;">&#40;</span>dataSource<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        <span style="color: #aaaadd; font-weight: bold;">List</span> lparams <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>startDate, endDate<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">;</span>
        <span style="color: #000000; font-weight: bold;">def</span> query2 <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;select * from invoiceh where trx_date between ? and ? &quot;</span><span style="color: #66cc66;">;</span>
        <span style="color: #000000; font-weight: bold;">def</span> result <span style="color: #66cc66;">=</span> sql.<span style="color: #006600;">rows</span><span style="color: #66cc66;">&#40;</span>query2,lparams<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        ......  <span style="color: #808080; font-style: italic;">// fetch the result into your gsp / you can process it further</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>This code will return result as array / collections.<br />
Simple isn&#8217;t it ?
</p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=57a2f476-2a53-8865-b811-e18917781825" /></div>
]]></content:encoded>
			<wfw:commentRss>http://www.wysmedia.com/2009/05/native-sql-query-on-grails/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using Liquibase (tutorial)</title>
		<link>http://www.wysmedia.com/2009/02/using-liquibase-tutorial/</link>
		<comments>http://www.wysmedia.com/2009/02/using-liquibase-tutorial/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 02:52:17 +0000</pubDate>
		<dc:creator>adwin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[database migration]]></category>
		<category><![CDATA[liquibase]]></category>

		<guid isPermaLink="false">http://www.wysmedia.comyr.com/?p=27</guid>
		<description><![CDATA[http://www.liquibase.org/manual/]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.liquibase.org">Liquibase</a> is the powerful database migration that available for free. For long time I am envy of rails database migration system. It is nice and have rich features. </p>
<p>Few weeks ago, I found that <a href='http://grails.org'> Grails </a> has Liquibase plugin (there are 2, liquibase and autobase). I tried both plugins and autobase won my heart because the simplicity they offer (not using XML is the biggest advantages, for me at least). Liquibase however build as stand alone java application that you can run with any operating system that support java.</p>
<p> Here I will show you how to configure and using Liquibase on command line, so you can apply whether you are using php, python, or others programming language/framework </p>
<p><span id="more-27"></span></p>
<ul>
<li> First, download and extract Liquibase files from <a href='www.liquibase.org'>www.liquibase.org</a></li>
<li> Create a file named liquibase.properties </li>
<li> Write the following, you can modify it to suit your needs

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">classpath: ../;lib/mysql-connector-java-5.1.6-bin.jar
changeLogFile=changelogs/root.changelog.xml
username=root
password=
url=jdbc:mysql://localhost/tester
driver=com.mysql.jdbc.Driver
logLevel=SEVERE</pre></td></tr></table></div>

<p>* you must download mysql-connector-java-5.xxxx.jar (mysql jdbc driver) from <a href='www.mysql.com'>www.mysql.com</a>
</li>
<li>Create a directory <b>changelogs</b></li>
<li>Inside, create root.changelog.xml and write the following

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;databaseChangeLog</span></span>
<span style="color: #009900;">        <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.liquibase.org/xml/ns/dbchangelog/1.7&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://www.liquibase.org/xml/ns/dbchangelog/1.7 http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.7.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;preConditions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dbms</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;mysql&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sqlCheck</span> <span style="color: #000066;">expectedResult</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>select 1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sqlCheck<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;runningAs</span> <span style="color: #000066;">username</span>=<span style="color: #ff0000;">&quot;root&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/preConditions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;changeSet</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">author</span>=<span style="color: #ff0000;">&quot;nvoxland&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            You can add comments to changeSets.
            They can even be multiple lines if you would like.
            They aren't used to compute the changeSet MD5Sum, so you can update them whenever you want without causing
            problems.
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;createTable</span> <span style="color: #000066;">tableName</span>=<span style="color: #ff0000;">&quot;person&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;column</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;id&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;int&quot;</span> <span style="color: #000066;">autoIncrement</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constraints</span> <span style="color: #000066;">primaryKey</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">nullable</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/column<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;column</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;firstname&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;varchar(50)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;column</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;lastname&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;varchar(50)&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constraints</span> <span style="color: #000066;">nullable</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/column<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/createTable<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/changeSet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;changeSet</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">author</span>=<span style="color: #ff0000;">&quot;nvoxland&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Add a username column so we can use &quot;person&quot; for authentication<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;addColumn</span> <span style="color: #000066;">tableName</span>=<span style="color: #ff0000;">&quot;person&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;column</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;usernae&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;varchar(8)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/addColumn<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/changeSet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;changeSet</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #000066;">author</span>=<span style="color: #ff0000;">&quot;nvoxland&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Fix misspelled &quot;username&quot; column<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;renameColumn</span> <span style="color: #000066;">tableName</span>=<span style="color: #ff0000;">&quot;person&quot;</span> <span style="color: #000066;">oldColumnName</span>=<span style="color: #ff0000;">&quot;usernae&quot;</span> <span style="color: #000066;">newColumnName</span>=<span style="color: #ff0000;">&quot;username&quot;</span> <span style="color: #000066;">columnDataType</span>=<span style="color: #ff0000;">&quot;varchar(8)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/changeSet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/databaseChangeLog<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

</li>
<li>When you finished, go to command line and type :<br />
<blockquote><p>java -jar liquibase-1.9.0.jar migrate</p></blockquote>
</li>
<li> This command will create databasechangelog and databasechangeloglock first. Databasechangelog contains record migration that you have done in the past. If you delete one record, next time you run migrate, it will re-run again</li>
</ul>
<p>Now I will explain what is inside the changelog </p>
<p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;databaseChangeLog</span></span>
<span style="color: #009900;">        <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.liquibase.org/xml/ns/dbchangelog/1.7&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://www.liquibase.org/xml/ns/dbchangelog/1.7 http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.7.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;preConditions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dbms</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;mysql&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sqlCheck</span> <span style="color: #000066;">expectedResult</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>select 1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sqlCheck<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;runningAs</span> <span style="color: #000066;">username</span>=<span style="color: #ff0000;">&quot;root&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/preConditions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
..... 
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/databaseChangeLog<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>It is the header of changelog that you need to have.<br />
There are preConditions tag that will help you to know whether the database is mysql or not. </p>
<p>next :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;changeSet</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">author</span>=<span style="color: #ff0000;">&quot;nvoxland&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            You can add comments to changeSets.
            They can even be multiple lines if you would like.
            They aren't used to compute the changeSet MD5Sum, so you can update them whenever you want without causing
            problems.
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;createTable</span> <span style="color: #000066;">tableName</span>=<span style="color: #ff0000;">&quot;person&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;column</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;id&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;int&quot;</span> <span style="color: #000066;">autoIncrement</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constraints</span> <span style="color: #000066;">primaryKey</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">nullable</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/column<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;column</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;firstname&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;varchar(50)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;column</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;lastname&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;varchar(50)&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constraints</span> <span style="color: #000066;">nullable</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/column<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/createTable<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/changeSet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>This change set will generate a table Person for you. having column firstname and lastName</p>
<p>next:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;changeSet</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">author</span>=<span style="color: #ff0000;">&quot;nvoxland&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Add a username column so we can use &quot;person&quot; for authentication<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;addColumn</span> <span style="color: #000066;">tableName</span>=<span style="color: #ff0000;">&quot;person&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;column</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;usernae&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;varchar(8)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/addColumn<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/changeSet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>The second update will add &#8220;usernae&#8221; (typo mistakes is on purpose) with width 8 characters</p>
<p>next: we need to fix the usernae become username</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;changeSet</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #000066;">author</span>=<span style="color: #ff0000;">&quot;nvoxland&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Fix misspelled &quot;username&quot; column<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;renameColumn</span> <span style="color: #000066;">tableName</span>=<span style="color: #ff0000;">&quot;person&quot;</span> <span style="color: #000066;">oldColumnName</span>=<span style="color: #ff0000;">&quot;usernae&quot;</span> <span style="color: #000066;">newColumnName</span>=<span style="color: #ff0000;">&quot;username&quot;</span> <span style="color: #000066;">columnDataType</span>=<span style="color: #ff0000;">&quot;varchar(8)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/changeSet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

</p>
<p>
They are lots of command that you can use on Liquibase, just make sure you read the manual first on <a href="http://www.liquibase.org/manual/">http://www.liquibase.org/manual/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.wysmedia.com/2009/02/using-liquibase-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- www.000webhost.com Analytics Code -->
<script type="text/javascript" src="http://analytics.hosting24.com/count.php"></script>
<noscript><a href="http://www.hosting24.com/"><img src="http://analytics.hosting24.com/count.php" alt="web hosting" /></a></noscript>
<!-- End Of Analytics Code -->
