Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 998
Mahmoud Saleh Avatar asked Mar 24 '11 12:03

Mahmoud Saleh


People also ask

What is timestamp without timezone in PostgreSQL?

The timestamp datatype allows you to store both date and time. However, it does not have any time zone data. It means that when you change the timezone of your database server, the timestamp value stored in the database will not change automatically.

What is the format of timestamp in PostgreSQL?

Postgres DATE data type Postgres uses the DATE data type for storing different dates in YYYY-MM-DD format. It uses 4 bytes for storing a date value in a column. You can design a Postgres table with a DATE column and use the keyword DEFAULT CURRENT_DATE to use the current system date as the default value in this column.


1 Answers

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>
like image 97
magomarcelo Avatar answered Oct 08 '22 05:10

magomarcelo