diff --git a/migrations/2024-05-18-231505_add_user_admin/down.sql b/migrations/2024-05-18-231505_add_user_admin/down.sql new file mode 100644 index 0000000..8c2de0f --- /dev/null +++ b/migrations/2024-05-18-231505_add_user_admin/down.sql @@ -0,0 +1 @@ +ALTER TABLE users DROP COLUMN admin; diff --git a/migrations/2024-05-18-231505_add_user_admin/up.sql b/migrations/2024-05-18-231505_add_user_admin/up.sql new file mode 100644 index 0000000..58a6e49 --- /dev/null +++ b/migrations/2024-05-18-231505_add_user_admin/up.sql @@ -0,0 +1 @@ +ALTER TABLE users ADD COLUMN admin BOOLEAN DEFAULT FALSE NOT NULL; diff --git a/src/models.rs b/src/models.rs index 442713e..349ed74 100644 --- a/src/models.rs +++ b/src/models.rs @@ -41,6 +41,8 @@ pub struct User { /// The time the user was created #[cfg_attr(feature = "ssr", diesel(deserialize_as = SystemTime))] pub created_at: Option, + /// Whether the user is an admin + pub admin: bool, } /// Model for an artist diff --git a/src/pages/signup.rs b/src/pages/signup.rs index 69f68c7..f02dfab 100644 --- a/src/pages/signup.rs +++ b/src/pages/signup.rs @@ -25,6 +25,7 @@ pub fn Signup() -> impl IntoView { email: email.get(), password: Some(password.get()), created_at: None, + admin: false, }; log!("new user: {:?}", new_user); diff --git a/src/schema.rs b/src/schema.rs index 97de324..e4964b9 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -50,6 +50,7 @@ diesel::table! { email -> Varchar, password -> Varchar, created_at -> Timestamp, + admin -> Bool, } }