0
Under review

[Postgres] Migration Script Error - SET DEFAULT now()

Fernando Santos 9 months ago updated by Jarosław Błąd (CEO) 9 months ago 1

Hi there!

I generated a migration SQL script for Postgres physical data Model, but it didn't work properly.


One of the changes was setting a default for a timestamp column, using now() function as the default value.

The ALTER TABLE command generated by the migration feature was:


-- Column: created_at.
ALTER TABLE rq_forms
ALTER created_at SET DEFAULT 'now()';


However, it creates the default with a fixed timestamp, the date and time of the ALTER TABLE execution.

The expected behavior was setting now() function as the default, not the fixed date and time.

This is the correct script the migration feature should generate: 

-- Column: created_at.
ALTER TABLE rq_forms
ALTER created_at SET DEFAULT now(); --> Without the single quotes.

Just to mention, the CREATE TABLE is working fine, setting the now() function properly when I generate the SQL Script for the same table in the model as seen below. Just ALTER TABLE generated by the migration has the bug.

-- Its OK!

CREATE TABLE rq_forms (
id serial NOT NULL,
created_at timestamp NOT NULL DEFAULT now(),
updated_at timestamp NULL,

(...)


One more request:

Vertabelo could have the type "timestamp with time zone" in the Type windows predefined options (in the Date and time section).

The "timestamp" option creates a "timestamp without time zone" column.

It would be nice to have the option to choose between with or without time zone in Vertabelo.

I hope I could help improving Vertabelo.


Regards,


Fernando dos Santos.

+1
Under review

Hello Fernando,

Thank you for reporting this issue. I can confirm that there is a bug, "now()" phrase should not be quoted in a migration script. We will put it into our backlog of issues. 

Best regards,

Jarosław