Skip to content

Can I use postgresql "CURRENT_TIMESTAMP" as a default value? #346

Answered by billy1624
GiyoMoon asked this question in Q&A
Discussion options

You must be logged in to vote

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:

  • #[test]
    fn create_4() {
    assert_eq!(
    Table::create()
    .table(Glyph::Table)
    .col(
    ColumnDef::new(Glyph::Id)
    .integer()
    .not_null()
    .extra("ANYTHING I WANT TO SAY".to_owned())
    )
    .to_string(MysqlQueryBuilder),
    vec![
    "CREATE TABLE `glyph` (",
    "`id` int NOT NULL ANYTHING I WANT TO SAY",
    ")",
    ]
    .join(" ")
    );
    }
  • e.g. .extra("DEFAULT CURRENT_TIMESTAMP".to_string())

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@GiyoMoon
Comment options

@billy1624
Comment options

Answer selected by GiyoMoon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants