7

when i tried to create a column with the data type "TIMESTAMP WITHOUT TIME ZONE" in postgresql it's always created in the database as "TIMESTAMP WITH TIME ZONE" , so is there's any workarounds or solutions for this problem ?

<addColumn tableName="myTable">
            <column name="date_added" type="TIMESTAMP WITHOUT TIME ZONE">
            <constraints nullable="false" />
            </column>
 </addColumn>

btw, this issue is on jira: http://liquibase.jira.com/browse/CORE-877

2
  • 2
    Keep in mind Liquibase is interpreting XML tags into PostgreSQL SQL commands. To be sure what SQL is being executed run Liquibase with the updateSQL option to see what the actual SQL being generated is. Commented Mar 24, 2011 at 14:10
  • 3
    Can't you fix this bug in Liquibase? That's where the real problem is, Liquibase creates the wrong SQL. Commented Mar 24, 2011 at 18:34

5 Answers 5

12

Instead of using the tag and switch completely from XML to sql, you could modify the resulting generated SQL using the tag which is valid across the whole changeset: http://www.liquibase.org/documentation/modify_sql.html

for example in your case you would have this:

<modifySql dbms="postgresql">
    <replace replace="WITH" with="WITHOUT"/>
</modifySql>
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! It works great. One tip: The modifySql element goes inside the changeSet element and works across the whole changeSet. However, it was valid only if I place the modifySql element inside but at the end of the changeSet. And the current link is liquibase.org/documentation/modify_sql.html
3

Read this page http://www.liquibase.org/documentation/sql_format.html. just manually type in the needed SQL exactly how you want it if you use the SQL format with Liquibase.

Comments

2

After a long time since this query, liquibase team has already corrected this problem and now you can add following column type:

<column name="created_at" type="TIMESTAMP WITHOUT TIME ZONE">
    <constraints nullable="true"/>
</column>

Comments

1

You could use the <sql> tag to create the exact SQL you are wanting if liquibase is generating the wrong SQL for you.

2 Comments

@sword101 I think this is what you need to look at liquibase.org/manual/custom_sql.
@StarShip3000 Yes, I forgot to escape the angle brackets around the sql tag and so it didn't show. Sorry about that
0

In addition to @magomarcelo you can also write modifysql as a YAML. The following example ignores unsigned in postgresql:

- modifySql:
    dbms: postgresql
    replace:
      replace: unsigned
      with: default 0

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.