Mahmoud Saleh
Mahmoud Saleh

Reputation: 33635

Cannot create column with type "TIMESTAMP WITHOUT TIME ZONE" in PostgreSQL

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

Upvotes: 7

Views: 11965

Answers (5)

Oskarro
Oskarro

Reputation: 413

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>

Upvotes: 2

Mistriel
Mistriel

Reputation: 529

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

Upvotes: 0

magomarcelo
magomarcelo

Reputation: 370

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>

Upvotes: 12

Kuberchaun
Kuberchaun

Reputation: 30362

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.

Upvotes: 3

Nathan Voxland
Nathan Voxland

Reputation: 15783

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

Upvotes: 1

Related Questions