-
Hey, I'm using sea-orm with sea-query to create migrations which set up my postgresql database. I was wondering if it is possible to set Table::create()
.table(User::Entity)
.if_not_exists()
.col(ColumnDef::new(User::Id).uuid().not_null().primary_key())
.col(
ColumnDef::new(User::CreatedAt)
.timestamp()
.default() // <== HERE, I would like to set CURRENT_TIMESTAMP as the default value
.not_null(),
);
#[derive(Iden)]
pub enum User {
Entity,
Id,
CreatedAt,
} Should generate: CREATE TABLE user (
id UUID PRIMARY KEY
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
); Btw awesome query builder and ORM crates! I love using them :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hey @GiyoMoon, currently there is no official way of doing it. I just opened an issue tracking this: At the meantime, you can use
|
Beta Was this translation helpful? Give feedback.
Hey @GiyoMoon, currently there is no official way of doing it. I just opened an issue tracking this:
At the meantime, you can use
extra
method as a workaround:sea-query/tests/mysql/table.rs
Lines 114 to 133 in 6c9527a
.extra("DEFAULT CURRENT_TIMESTAMP".to_string())