Hello, I need some help with connecting Postgresql and amplify gen 2 project.
How to correctly create postress Table with createdAt and updatedAt fields, to make them same as createdAt updatedAt as native.
Here is my current sql query for table creation
CREATE TABLE account (
id VARCHAR(255) PRIMARY KEY,
"createdAt" TIMESTAMP default CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP default CURRENT_TIMESTAMP
);
In documentation stated that amplify automaticaly handle those fields if they are presented in schema, however, its not true, there are two issues
1 amplify do not auto update those fields on record update (tried to define them with with names like updated_at or "updatedAt")
- wrong type generated in schema (createdAt or updatedAt fields) doesn't have default values, and stated as Nullable after record creation
file schema.sql.ts
....
.schema({
"account": a.model({
id: a.string().required(),
createdAt: a.datetime(),
updatedAt: a.datetime()
}).identifier([
"id"
])
How to define these fields (createdAt, updatedAt) in postgresql to make them behave like fields when using dynamo db tabels?