Skip to main content

create_table

Function create_table 

Source
pub fn create_table<M: Model>() -> CreateTable<M>
Expand description

Create a table for a model type.

§Example

use sqlmodel::{Model, create_table};

#[derive(Model)]
struct Hero {
    id: Option<i64>,
    name: String,
}

// Generate CREATE TABLE SQL
let sql = create_table::<Hero>().if_not_exists().build();