How to make default label columns behave?

I am trying to get these columns to do two things:

  • Use a timestamp without a time zone (backend - Postgres).
  • Actually set the default value for the backend to "now / utc".

        {
            // a bunch of column definitions
            createdAt: { type: DataTypes.DATE, defaultValue: sequelize.fn('now') }
        }, 
        {
            timestamps: false,
            comment: "this isn't even the real comment"
        }
    

The results are as follows:

CREATE TABLE IF NOT EXISTS "common"."images" ("id" VARCHAR(255) , "imageType"
VARCHAR(255), "mimeType" TEXT, "source" VARCHAR(255), "path" TEXT UNIQUE, 
"createdAt" TIMESTAMP WITH TIME ZONE DEFAULT now(), PRIMARY KEY ("id")); 
COMMENT ON TABLE "common"."images" IS 'blah blah blah.';

However, I cannot find the documentation on how I can make it be timestamp-without-tz, or how I can do the default "now () in the time zone" utc "".

Are any of these options possible?

If possible, is it possible to do this without setting the timestamps to false and manually defining the column, how did I do this?

+4
source share
2 answers

-, . Sequelize "" , ( ) , .

{
    // a bunch of column definitions
    createdAt: { type: DataTypes.DATE, defaultValue: sequelize.literal("(now() at time zone 'utc')") }
}, 

, Postgres "utc" .

, , Sequelize " ", . , , , .

+2

sequelize, options.timezone UTC, , , NOW() UTC. . . : http://sequelize.readthedocs.org/en/latest/api/sequelize/

postgresql.conf .

+1

All Articles