From 4cd75af8d2531e63fda33fab37f0785931a0219c Mon Sep 17 00:00:00 2001 From: Manuel Cillero Date: Fri, 2 Oct 2026 06:27:36 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20(seaorm):=20Crea=20timestamp()?= =?UTF-8?q?=20con=20zona=20horaria?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Las entidades guardan los instantes como DateTimeUtc, que PostgreSQL sólo lee desde TIMESTAMPTZ. timestamp() y timestamp_null() pasan a crear columnas con zona horaria; en MySQL y SQLite no cambia nada en la práctica. --- extensions/pagetop-seaorm/src/migration.rs | 2 +- extensions/pagetop-seaorm/src/migration/schema.rs | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) 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 {