X
Xata16h ago
1benw

"now" as default value for timestamp not working

When adding a new timestamp column in the xata web ui (using xata with postgres enabled), if you set the default value to be now, it sets the default value to the time at which you created the column instead of being the time when a new row is created.
No description
No description
1 Reply
tsg
tsg13h ago
thanks, I can replicate this and seems to be a pgroll issue. I'm speaking with the team to figure out what's going on and will report back. it seems there is an UI issue where we create the column using now instead of now(). I think we'll have the fix soon, but if you need a workaround in the meantime, you can create the column by using the Schema / Migration editor and then use something like this:
[
{
"add_column": {
"table": "test",
"column": {
"pk": false,
"name": "ts",
"type": "timestamptz",
"unique": false,
"comment": "",
"default": "now()",
"nullable": false
}
}
}
]
[
{
"add_column": {
"table": "test",
"column": {
"pk": false,
"name": "ts",
"type": "timestamptz",
"unique": false,
"comment": "",
"default": "now()",
"nullable": false
}
}
}
]
That's what the UI does, except that it uses now instead of now().
Want results from more Discord servers?
Add your server