diff --git a/extensions/pagetop-seaorm/src/migration.rs b/extensions/pagetop-seaorm/src/migration.rs index 0c974f06..412426aa 100644 --- a/extensions/pagetop-seaorm/src/migration.rs +++ b/extensions/pagetop-seaorm/src/migration.rs @@ -103,7 +103,7 @@ //! | `string_uniq(col)` | `VARCHAR NOT NULL UNIQUE` | //! | `integer(col)` | `INTEGER NOT NULL` | //! | `boolean(col)` | `BOOLEAN NOT NULL` | -//! | `timestamp(col)` | `TIMESTAMP NOT NULL` | +//! | `timestamp(col)` | `TIMESTAMP WITH TIME ZONE NOT NULL` | //! | `uuid(col)` | `UUID NOT NULL` | //! //! Estas son sólo las funciones más habituales. El módulo [`schema`] define la lista completa, con diff --git a/extensions/pagetop-seaorm/src/migration/schema.rs b/extensions/pagetop-seaorm/src/migration/schema.rs index 88ce8b13..1d645c5d 100644 --- a/extensions/pagetop-seaorm/src/migration/schema.rs +++ b/extensions/pagetop-seaorm/src/migration/schema.rs @@ -329,12 +329,16 @@ pub fn interval_uniq( interval(col, fields, precision).unique_key().take() } +// Unlike the original helpers, `timestamp()` and `timestamp_null()` create time zone aware +// columns. Entities store instants as `DateTimeUtc`, which PostgreSQL can only decode from +// `TIMESTAMPTZ`; a plain `TIMESTAMP` would also store `CURRENT_TIMESTAMP` in server local time. +// Keep this deviation when syncing with upstream. pub fn timestamp(col: T) -> ColumnDef { - ColumnDef::new(col).timestamp().not_null().take() + timestamp_with_time_zone(col) } pub fn timestamp_null(col: T) -> ColumnDef { - ColumnDef::new(col).timestamp().null().take() + timestamp_with_time_zone_null(col) } pub fn timestamp_uniq(col: T) -> ColumnDef {