使用 SQLAlchemy、alembic 和 postgres,当尝试将列设置为行创建时间时,我最终得到的是一个字段,该字段默认为创建表本身的时间,而不是创建行的时间。
型号代码:
datetime = sa.Column(sa.DateTime, nullable=False, server_default=func.now())
Alembic 将其翻译为:
sa.Column('datetime', sa.DateTime(), server_default='now()', nullable=False),
Postgres 中的专栏:
datetime | timestamp without time zone | not null default '2013-06-24 11:28:14.930524'::timestamp without time zone
我应该怎么做才能默认为行创建时间?