loco-rs / loco

🚂 🦀 The one-person framework for Rust for side-projects and startups
https://loco.rs
Apache License 2.0
3.89k stars 166 forks source link

How can I implement check function for postgresql in Loco? thank you #718

Closed HelloReboot closed 1 week ago

HelloReboot commented 3 weeks ago

CHECK (phone_number IS NOT NULL OR email IS NOT NULL);
how can i define this in db migration files?

trevoranderson commented 2 weeks ago

This is done by the ORM. Here's an adaptation from one of my tables.

  // check() is from sea-query's create.rs
  .check(Expr::col(MyTable::ColumnA).lt(Expr::col(MyTable::ColumnB)))
HelloReboot commented 2 weeks ago

thank you so much bro @trevoranderson