🐛 (seaorm): Crea timestamp() con zona horaria
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.
This commit is contained in:
parent
90e4f85bd4
commit
4cd75af8d2
2 changed files with 7 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -329,12 +329,16 @@ pub fn interval_uniq<T: IntoIden>(
|
|||
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<T: IntoIden>(col: T) -> ColumnDef {
|
||||
ColumnDef::new(col).timestamp().not_null().take()
|
||||
timestamp_with_time_zone(col)
|
||||
}
|
||||
|
||||
pub fn timestamp_null<T: IntoIden>(col: T) -> ColumnDef {
|
||||
ColumnDef::new(col).timestamp().null().take()
|
||||
timestamp_with_time_zone_null(col)
|
||||
}
|
||||
|
||||
pub fn timestamp_uniq<T: IntoIden>(col: T) -> ColumnDef {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue