New Topic: Idea for checking preconditions during updateSQL

View: New views
1 Messages — Rating Filter:   Alert me  

New Topic: Idea for checking preconditions during updateSQL

by LiquiBase Community Forum :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

A new topic, 'Idea for checking preconditions during updateSQL', has been made on a board you are watching.

You can see it at
http://liquibase.org/forum/index.php?topic=177.new#new

The text of the topic is shown below:

This was going to be another possible extension contest entry, but day-job demands got in the way...

Here's an idea for checking preconditions during updateSQL:

Create a DatabaseWrapper class which encapsulates a rolling DatabaseSnapshot and a regular Database.

Build an initial DatabaseSnapshot at startup.

Use new custom SqlGenerators to modify the rolling DatabaseSnapshot as appropriate for the statement (e.g. CreateTable, AddColumn, etc).

When a precondition asks for a DatabaseSnapshot, let the Wrapper serve up the rollingDatabaseSnapshot instead.

That way, if you have precondition dependencies, your updateSQL should take those into account.

For example,

Code:
   
   <changeSet id="1" author="cimershein">
         <createTable tableName="person">
            <column name="id" type="int" autoIncrement="true">
                <constraints primaryKey="true" nullable="false"/>
            </column>
            <column name="firstname" type="varchar(50)"/>
            <column name="lastname" type="varchar(50)">
                <constraints nullable="false"/>
            </column>
        </createTable>
    </changeSet>

    <changeSet id="2" author="cimershein">
        <preConditions>
            <tableExists tableName="person"/>
        </preConditions>
         <addColumn tableName="person">
            <column name="username" type="varchar(8)"/>
        </addColumn>
    </changeSet>


Chris Imershein

Unsubscribe to new topics from this board by clicking here: http://liquibase.org/forum/index.php?action=notifyboard;board=1.0

Regards,
The LiquiBase Community Forum Team.
------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Liquibase-user mailing list
Liquibase-user@...
https://lists.sourceforge.net/lists/listinfo/liquibase-user