Fixed option/nullable fields
This commit is contained in:
parent
3606cdf4ee
commit
035551629c
|
@ -1,8 +1,8 @@
|
|||
-- Your SQL goes here
|
||||
CREATE TABLE users (
|
||||
id SERIAL PRIMARY KEY,
|
||||
username VARCHAR(32),
|
||||
is_active BOOLEAN DEFAULT TRUE,
|
||||
username VARCHAR(32) UNIQUE NOT NULL,
|
||||
is_active BOOLEAN DEFAULT TRUE NOT NULL,
|
||||
created_at TIMESTAMPTZ DEFAULT now(),
|
||||
updated_at TIMESTAMPTZ DEFAULT NULL
|
||||
);
|
||||
|
|
|
@ -3,13 +3,12 @@ use chrono::{
|
|||
};
|
||||
use diesel::prelude::*;
|
||||
use diesel::PgConnection;
|
||||
use serde_derive::Serialize;
|
||||
|
||||
#[derive(Queryable, Debug)]
|
||||
pub struct User {
|
||||
pub id: i32,
|
||||
pub username: Option<String>,
|
||||
pub is_active: Option<bool>,
|
||||
pub username: String,
|
||||
pub is_active: bool,
|
||||
pub created_at: Option<NaiveDateTime>,
|
||||
pub updated_at: Option<NaiveDateTime>,
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@ table! {
|
|||
table! {
|
||||
users (id) {
|
||||
id -> Int4,
|
||||
username -> Nullable<Varchar>,
|
||||
is_active -> Nullable<Bool>,
|
||||
username -> Varchar,
|
||||
is_active -> Bool,
|
||||
created_at -> Nullable<Timestamptz>,
|
||||
updated_at -> Nullable<Timestamptz>,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue