• LiquiBase预判断



    预判断解决的问题:运行liquibase之前,DB中已经存在一个table,所以需要加上预判断;


    完整的一个例子:


    <?xml version="1.0" encoding="utf-8"?>
    <databaseChangeLog

        <property name="now" value="now()" dbms="mysql,h2"/>
        <property name="now" value="current_timestamp" dbms="postgresql"/>
        <property name="now" value="sysdate" dbms="oracle"/>

         
        <changeSet id="20151108112500" author="WWW">

    <!-- 预判断-->
            <preConditions onFail="MARK_RAN">
                <not>
                    <tableExists tableName="MYTABLE"/>
                </not>
            </preConditions>
            <createTable tableName="MYTABLE">
               <column name="id" type="bigint" autoIncrement="true">
                    <constraints primaryKey="true" nullable="false"/>
                </column>
                <column name="title" type="varchar(100)"/>
                <column name="content" type="text">
                    <constraints nullable="false" />
                </column>
                <column name="course_id" type="bigint"/>
                <column name="chapter_id" type="varchar(40)"/>
                <column name="user_id" type="bigint">
                     <constraints nullable="false" />
                </column>
                 <column name="reply_count" type="int"/>
                 <column name="same_ask_count" type="int"/>
                 <column name="browse_count" type="int"/>
                 <column name="time" type="bigint"/>
                <column name="status" type="varchar(10)"/>
                <column name="created_by" type="varchar(50)">
                    <constraints nullable="false"/>
                </column>
                <column name="created_date" type="timestamp" defaultValueDate="${now}">
                    <constraints nullable="false"/>
                </column>
                <column name="last_modified_by" type="varchar(50)"/>
                <column name="last_modified_date" type="timestamp"/>
            </createTable>
        </changeSet>
    </databaseChangeLog>

  • 相关阅读:
    移动端尺寸基础知识
    em与px换算
    ECharts是中国的,也是世界的。
    Sublime Text 使用介绍、全套快捷键及插件推荐
    HTML5 新属性placeholder 兼容ie
    链接属性rel=’external’、rel=’nofollow’、rel=’external nofollow’三种写法的区别
    关于文字内容溢出用点点点(...)省略号表示
    Hello World!
    C# 在类中使用session
    SQL Server2008函数大全
  • 原文地址:https://www.cnblogs.com/itrena/p/5927143.html
Copyright © 2020-2023  润新知